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