Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions @ether/ray/bootstrap/Ray.ray
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ assert (1..3).last == 3 // OR6 a range of numbers does not end at its last
assert (1..3).count == 3 // OR7 one to three is not three numbers
assert (3..1).first == 3 // OR8 a range going down does not begin where it is written to
assert (1..<3).count == 2 // OR9 one up to three holds other than two
// (repeated, `[0] * 3`: it, as many times as given, one after another)
Ray &+= {
* (times: Number) => {
made := Ray.new
left := times
while !left.is_zero {
made = made.joined(this)
left = left.pred
}
made
}
assert [0] * 3 == [0, 0, 0] // RP2 a list three times is not it three times
assert [1, 2] * 2 == [1, 2, 1, 2] // RP3 a list twice does not keep its order each time
assert ([1] * 0).empty // RP4 a list no times is something
}
15 changes: 15 additions & 0 deletions @ether/ray/bootstrap/String.ray
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ assert ` ` is \s[] // SP3 two spaces are not spaces
assert `ab` is String+ // SP4b a text of two is not one or more
assert `a b` is (String+, \s, String+) // SP5 a b is not a word, a space and a word
assert !(`ab` is (String+, \s, String+)) // SP6 ab is a word, a space and a word
// (repeated, `` `ab` * 2 ``: it, as many times as given, one after another)
String &+= {
* (times: Number) => {
made := `a`.rest
left := times
while !left.is_zero {
made = made + this
left = left.pred
}
made
}
assert `ab` * 2 == `abab` // RP5 a text twice is not it twice
assert `a` * 3 == `aaa` // RP7 a text three times is not it three times
assert (`ab` * 0).empty // RP6 a text no times is something
}
Loading