Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,31 @@
(define (person->string self) (format "%a : person." (person-name self)))
(define (writer->string self) (format "%a: writer of %a."
(person-name self)
(writer-books self)))
(define (father->string self) (format "%a: father of %a."
(person-name self)
(map person-name (father-children self))))
; 'classes' definition, with inheritance.
; a writer is a person, too.
(struct person (name) #:tostring person->string)
(struct writer person (books) #:tostring writer->string)
(struct father person (children) #:tostring father->string)
(define simon (writer "Simon" '(my-life my-wife my-bike)))
(define elvis (person "Elvis"))
(define papa (father "papa" (list simon elvis)))
(local-put-value 'simon simon "objects.dat")
📕 local-db: local-put:unknown store : "objects.dat"
;; forgot to create the store. Create it :
(local-make-store "objects.dat") → "objects.dat"
(local-put-value 'simon simon "objects.dat")
(local-put-value 'elvis elvis "objects.dat")
(local-put-value 'papa papa "objects.dat")
;; inspect
simon → Simon: writer of (my-life my-wife my-bike).
papa → papa: father of (Simon Elvis).
elvis → Elvis : person.

View file

@ -0,0 +1,28 @@
;; reboot (close the browser window)
; inspect objects.dat :
(local-keys 'objects.dat) → ("elvis" "papa" "simon")
(define simon (local-get-value 'simon "objects.dat"))
(define elvis (local-get-value 'elvis "objects.dat"))
(define papa (local-get-value 'papa "objects.dat"))
; data are restored
simon → Simon: writer of (my-life my-wife my-bike).
papa → papa: father of (Simon Elvis).
;; check if references (pointers) are restored
(set-writer-name! simon "Antoinette") → "Antoinette"
simon→ Antoinette: writer of (my-life my-wife my-bike).
;; inspect
papa → papa: father of (Antoinette Elvis). ; YES 😳 !
;; - Self-referencing (EchoLisp version 2.11)
;; add 'papa' to the chidren of 'papa' - whatever this means - and print it :
(set-father-children! papa (list simon papa elvis))
papa → papa: father of (Antoinette papa Elvis).
; save/restore
(local-put-value 'papa papa "objects.dat")
(define papa (local-get-value 'papa "objects.dat"))
papa → papa: father of (Antoinette papa Elvis).