Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Stack/EchoLisp/stack.echolisp
Normal file
20
Task/Stack/EchoLisp/stack.echolisp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
; build stack [0 1 ... 9 (top)] from a list
|
||||
(list->stack (iota 10) 'my-stack)
|
||||
(stack-top 'my-stack) → 9
|
||||
(pop 'my-stack) → 9
|
||||
(stack-top 'my-stack) → 8
|
||||
(push 'my-stack '🐸) ; any kind of lisp object in the stack
|
||||
(stack-empty? 'my-stack) → #f
|
||||
(stack->list 'my-stack) ; convert stack to list
|
||||
→ (0 1 2 3 4 5 6 7 8 🐸)
|
||||
(stack-swap 'my-stack) ; swaps two last items
|
||||
→ 8 ; new top
|
||||
(stack->list 'my-stack)
|
||||
→ (0 1 2 3 4 5 6 7 🐸 8) ; swapped
|
||||
(while (not (stack-empty? 'my-stack)) (pop 'my-stack)) ; pop until empty
|
||||
(stack-empty? 'my-stack) → #t ; true
|
||||
|
||||
(push 'my-stack 7)
|
||||
my-stack ; a stack is not a variable, nor a symbol - cannot be evaluated
|
||||
⛔ error: #|user| : unbound variable : my-stack
|
||||
(stack-top 'my-stack) → 7
|
||||
Loading…
Add table
Add a link
Reference in a new issue