-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.lisp
64 lines (55 loc) · 1.87 KB
/
example.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;; -----
;;
;; -*- mode: Lisp; -*-
;;
;; example.lisp
;;
;; load up the persidastricl library
(ql:quickload :persidastricl)
;;
;; now define the package where my code will go and use persidastricl there
;; NOTE: you have to shadow those things that are re-written from CL
;;
(defpackage #:example
(:use #:cl #:persidastricl)
(:shadowing-import-from #:persidastricl
#:assoc
#:atom
#:butlast
#:cons
#:count
#:delete
#:filter
#:first
#:get
#:keyword
#:last
#:length
#:map
#:merge
#:nth
#:pop
#:reduce
#:remove
#:replace
#:rest
#:second
#:set
#:some
#:third
#:vector))
;; get into the package to write our code
(in-package #:example)
;; turn on the syntax in the example package
(named-readtables:in-readtable persidastricl:syntax)
;; now write some code (all this below is very contrived and just pointless besides for demo!!)
(def m {:A 0 :a 1 :b 2 :c 3 :d {:e #{1 2 3 4 5} :f [1 2 3 4 5] :g '(9 8 7 6 5)}})
;; BEWARE: notice that in the persidastricl world things are case-sensitive
;;
;; WARNING: you will get evaluation warnings here about unused vars ... the '_ and the 'my-map vars (for this example, nbd)
;;
(defun doit ()
(dlet (({:keys [A a b] {:keys [f]} :d :as my-map} m)
([_ _ third] (get-in m [:d :f])))
[A a b f third]))
(doit)