fix bug in rest
with error on empty list
This commit is contained in:
parent
2c1de39161
commit
42492c8a09
|
@ -134,6 +134,8 @@ fn fn? {
|
||||||
& what we need for some very basic list manipulation
|
& what we need for some very basic list manipulation
|
||||||
fn rest {
|
fn rest {
|
||||||
"Returns all but the first element of a list or tuple, as a list."
|
"Returns all but the first element of a list or tuple, as a list."
|
||||||
|
([]) -> []
|
||||||
|
(()) -> ()
|
||||||
(xs as :list) -> base :rest (xs)
|
(xs as :list) -> base :rest (xs)
|
||||||
(xs as :tuple) -> base :rest (xs)
|
(xs as :tuple) -> base :rest (xs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,7 @@
|
||||||
(comment
|
(comment
|
||||||
# (do
|
# (do
|
||||||
(def source `
|
(def source `
|
||||||
hideturtle! ()
|
rest ([])
|
||||||
showturtle! ()
|
|
||||||
penup! ()
|
|
||||||
pendown! ()
|
|
||||||
pencolor! (colors :red)
|
|
||||||
`)
|
`)
|
||||||
(def out (-> source
|
(def out (-> source
|
||||||
ludus
|
ludus
|
||||||
|
|
Loading…
Reference in New Issue
Block a user