fix slice
This commit is contained in:
parent
27b1bb4e50
commit
7bdaf291a0
|
@ -649,7 +649,7 @@ fn last {
|
||||||
|
|
||||||
fn butlast {
|
fn butlast {
|
||||||
"Returns a list, omitting the last element."
|
"Returns a list, omitting the last element."
|
||||||
(xs as :list) -> base :slice (xs, dec (count (xs)))
|
(xs as :list) -> base :slice (xs, 0, dec (count (xs)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn slice {
|
fn slice {
|
||||||
|
@ -659,10 +659,7 @@ fn slice {
|
||||||
gte? (start, end) -> []
|
gte? (start, end) -> []
|
||||||
gt? (end, count (xs)) -> slice (xs, start, count (xs))
|
gt? (end, count (xs)) -> slice (xs, start, count (xs))
|
||||||
neg? (start) -> slice (xs, 0, end)
|
neg? (start) -> slice (xs, 0, end)
|
||||||
true -> {
|
true -> base :slice (xs, start, end)
|
||||||
let slice = base :slice (xs, inc (start), inc (end))
|
|
||||||
base :into ([], slice)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(str as :string, end as :number) -> base :str_slice (str, 0, end)
|
(str as :string, end as :number) -> base :str_slice (str, 0, end)
|
||||||
(str as :string, start as :number, end as :number) -> base :str_slice (str, start, end)
|
(str as :string, start as :number, end as :number) -> base :str_slice (str, start, end)
|
||||||
|
|
|
@ -281,7 +281,7 @@
|
||||||
"round" math/round
|
"round" math/round
|
||||||
"show" show
|
"show" show
|
||||||
"sin" math/sin
|
"sin" math/sin
|
||||||
"slice" slice
|
"slice" array/slice
|
||||||
"split" string/split
|
"split" string/split
|
||||||
"sqrt" math/sqrt
|
"sqrt" math/sqrt
|
||||||
"store!" store!
|
"store!" store!
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
(comment
|
(comment
|
||||||
# (do
|
# (do
|
||||||
(def source `
|
(def source `
|
||||||
forward! (100)
|
butlast ([1, 2, 3])
|
||||||
`)
|
`)
|
||||||
(def out (-> source
|
(def out (-> source
|
||||||
ludus
|
ludus
|
||||||
|
|
Loading…
Reference in New Issue
Block a user