This commit is contained in:
Bob Nystrom
2015-04-22 07:45:39 -07:00
2 changed files with 17 additions and 16 deletions

View File

@ -63,8 +63,9 @@ Iterates over the sequence, passing each element to the given `function`.
### **join**(sep)
Returns a string representation of the list. The string representations of the
elements in the list is concatenated with intervening occurrences of `sep`.
Returns a string representation of the sequence. The string representations of
the elements in the sequence is concatenated with intervening occurrences of
`sep`.
It is a runtime error if `sep` is not a string.
@ -72,15 +73,6 @@ It is a runtime error if `sep` is not a string.
Calls `join` with the empty string as the separator.
### **list**
Creates a [list](list.html) containing all the elements in the sequence.
:::dart
(1..3).list // [1, 2, 3].
If the sequence is already a list, this creates a copy of it.
### **map**(transformation)
Creates a new sequence that applies the `transformation` to each element in the
@ -100,11 +92,11 @@ This means you can use `map(_)` for things like infinite sequences or sequences
that have side effects when you iterate over them. But it also means that
changes to the original sequence will be reflected in the mapped sequence.
To force eager evaluation, just call `.list` on the result.
To force eager evaluation, just call `.toList` on the result.
:::dart
var numbers = [1, 2, 3]
var doubles = numbers.map {|n| n * 2 }.list
var doubles = numbers.map {|n| n * 2 }.toList
numbers.add(4)
IO.print(doubles) // [2, 4, 6].
@ -123,6 +115,15 @@ It is a runtime error to call this on an empty sequence.
Similar to above, but uses `seed` for the initial value of the accumulator. If
the sequence is empty, returns `seed`.
### **toList**
Creates a [list](list.html) containing all the elements in the sequence.
:::dart
(1..3).toList // [1, 2, 3].
If the sequence is already a list, this creates a copy of it.
### **where**(predicate)
Creates a new sequence containing only the elements from the original sequence
@ -146,10 +147,10 @@ sequences that have side effects when you iterate over them. But it also means
that changes to the original sequence will be reflected in the filtered
sequence.
To force eager evaluation, just call `.list` on the result.
To force eager evaluation, just call `.toList` on the result.
:::dart
var numbers = [1, 2, 3, 4, 5, 6]
var odds = numbers.where {|n| n % 2 == 1 }.list
var odds = numbers.where {|n| n % 2 == 1 }.toList
numbers.add(7)
IO.print(odds) // [1, 3, 5].

View File

@ -154,7 +154,7 @@ WrenMethod* wrenGetMethod(WrenVM* vm, const char* module, const char* variable,
// Calls [method], passing in a series of arguments whose types must match the
// specifed [argTypes]. This is a string where each character identifies the
// type of a single argument, in orde. The allowed types are:
// type of a single argument, in order. The allowed types are:
//
// - "b" - A C `int` converted to a Wren Bool.
// - "d" - A C `double` converted to a Wren Num.