2014-02-16 09:20:31 -08:00
|
|
|
class Sequence {
|
2014-02-18 11:54:55 -06:00
|
|
|
map(f) {
|
2014-02-16 09:20:31 -08:00
|
|
|
var result = []
|
|
|
|
|
for (element in this) {
|
|
|
|
|
result.add(f.call(element))
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-18 11:54:55 -06:00
|
|
|
where(f) {
|
2014-02-16 09:20:31 -08:00
|
|
|
var result = []
|
|
|
|
|
for (element in this) {
|
|
|
|
|
if (f.call(element)) result.add(element)
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class List is Sequence {
|
2014-04-06 08:37:37 -07:00
|
|
|
addAll(other) {
|
|
|
|
|
for (element in other) {
|
|
|
|
|
add(element)
|
|
|
|
|
}
|
|
|
|
|
return other
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 08:44:59 -08:00
|
|
|
toString {
|
|
|
|
|
var result = "["
|
2014-02-12 17:33:35 -08:00
|
|
|
for (i in 0...count) {
|
2014-02-04 08:44:59 -08:00
|
|
|
if (i > 0) result = result + ", "
|
|
|
|
|
result = result + this[i].toString
|
|
|
|
|
}
|
|
|
|
|
result = result + "]"
|
|
|
|
|
return result
|
|
|
|
|
}
|
2014-02-14 11:09:02 -06:00
|
|
|
|
2014-04-08 17:54:37 -07:00
|
|
|
+(other) {
|
2014-02-14 20:10:41 -08:00
|
|
|
var result = this[0..-1]
|
2014-04-08 17:54:37 -07:00
|
|
|
for (element in other) {
|
2014-02-14 17:24:06 -08:00
|
|
|
result.add(element)
|
2014-02-14 11:09:02 -06:00
|
|
|
}
|
2014-02-14 17:24:06 -08:00
|
|
|
return result
|
2014-02-14 11:09:02 -06:00
|
|
|
}
|
2014-02-04 08:44:59 -08:00
|
|
|
}
|
2014-02-16 09:20:31 -08:00
|
|
|
|
|
|
|
|
class Range is Sequence {}
|