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
22
Task/History-variables/EchoLisp/history-variables.echolisp
Normal file
22
Task/History-variables/EchoLisp/history-variables.echolisp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(define-syntax-rule (make-h-var name) (define name (stack (gensym))))
|
||||
(define-syntax-rule (h-get name) (stack-top name))
|
||||
(define-syntax-rule (h-set name value) (push name value))
|
||||
(define-syntax-rule (h-undo name)
|
||||
(begin
|
||||
(pop name)
|
||||
(when ( stack-empty? name) (error "no more values" 'name))
|
||||
(stack-top name)))
|
||||
|
||||
(define-syntax-rule (h-values name) (stack->list name))
|
||||
;; usage
|
||||
(make-h-var x)→ x
|
||||
|
||||
(h-set x 42) → 42
|
||||
(h-set x 666)→ 666
|
||||
(h-set x 'elvis)→ elvis
|
||||
(h-values x) → (42 666 elvis) ;; historized values
|
||||
|
||||
(h-get x) → elvis
|
||||
(h-undo x)→ 666
|
||||
(h-undo x) → 42
|
||||
(h-undo x) → ❌ error: no more values x
|
||||
Loading…
Add table
Add a link
Reference in a new issue