Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- : nil? nil = ;
- : not-nil? nil? invert ;
- : cons ( tail, head -- consc ) , , HERE 2 cells - ;
- : head ( consc -- e ) @ ;
- : tail ( consc -- e ) 1 cells + @ ;
- : even? ( n -- bool ) 2 mod 0 = ;
- : odd? ( n -- bool ) even? invert ;
- nil 1 cons head 1 = .
- nil 1 cons tail nil = .
- nil 2 cons 1 cons head 1 = .
- nil 2 cons 1 cons tail head 2 = .
- nil 2 cons 1 cons tail tail nil = .
- nil 3 cons 2 cons 1 cons head 1 = .
- nil 3 cons 2 cons 1 cons CONSTANT alist
- alist head 1 = .
- alist tail head 2 = .
- 2 even? .
- 3 odd? .
- : filter ( pred, consc -- consc ) recursive
- 2dup not-nil? if
- over dup head rot execute if
- tail swap head cons filter
- else
- drop tail filter
- then
- else
- drop nip
- then ;
- ' odd? alist filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement