lasp 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +1 -0
- data/lib/lasp.rb +1 -1
- data/lib/lasp/stdlib.lasp +120 -122
- data/lib/lasp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 834e32aec6fd535ecec0d68c7297cb3184ced218
|
4
|
+
data.tar.gz: ccc67e45c0aeb24b368a51a6bcea67d09af86db9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca7f8e586069ed34fa69c03c9c3b16a789b25b695e342d7e2124e5c1b6a9c7b5a23d12cfa4fa329b8668bcb24597ff1e4c8626a39888622369db3e20addab53e
|
7
|
+
data.tar.gz: 32229cfbb3e1c039249adcedacd75a8e50b3ad3ef0c71f3b0e522d8d5816a5d48429ddd9fa540157d7923b77a195bd46fe921d8b2d8f8086110896e2d1286675
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Läsp changelog
|
2
2
|
|
3
|
+
## v0.4.0
|
4
|
+
|
5
|
+
Implicit do-blocks around files. You can now do this...:
|
6
|
+
|
7
|
+
```lisp
|
8
|
+
(def x 5)
|
9
|
+
|
10
|
+
(def y 10)
|
11
|
+
```
|
12
|
+
|
13
|
+
...in a Läsp file without having to wrap the entire contents of the file in
|
14
|
+
`(do ...)`. Previously it just stopped reading after the first form and
|
15
|
+
anything after would seemingly inexplicably not be run.
|
16
|
+
|
17
|
+
**This is only enabled in files, not every form of evaluation.**
|
18
|
+
|
3
19
|
## v0.3.2
|
4
20
|
|
5
21
|
Fix bug in `do` - it accidentally returned part of the AST, now it correctly
|
data/README.md
CHANGED
data/lib/lasp.rb
CHANGED
data/lib/lasp/stdlib.lasp
CHANGED
@@ -1,122 +1,120 @@
|
|
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
|
-
(fn (coll)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
(
|
58
|
-
(
|
59
|
-
|
60
|
-
|
61
|
-
(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
(
|
68
|
-
(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
(
|
75
|
-
(
|
76
|
-
(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
(
|
83
|
-
(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
(
|
88
|
-
(
|
89
|
-
(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
(
|
95
|
-
(
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
(
|
102
|
-
(
|
103
|
-
(
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
(
|
109
|
-
(
|
110
|
-
(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
(
|
117
|
-
(
|
118
|
-
(
|
119
|
-
|
120
|
-
|
121
|
-
(tail coll))))
|
122
|
-
)
|
1
|
+
; Aliases
|
2
|
+
(def first head)
|
3
|
+
(def rest tail)
|
4
|
+
|
5
|
+
; Increment a number by one
|
6
|
+
(def inc (fn (x) (+ x 1)))
|
7
|
+
|
8
|
+
; Decrement a number by one
|
9
|
+
(def dec (fn (x) (- x 1)))
|
10
|
+
|
11
|
+
; If a list is empty
|
12
|
+
(def empty?
|
13
|
+
(fn (coll)
|
14
|
+
(= (head coll) nil)))
|
15
|
+
|
16
|
+
; Modulus
|
17
|
+
(def mod
|
18
|
+
(fn (x y) (- x (* (/ x y) y))))
|
19
|
+
|
20
|
+
; Returns a function that does the opposite of the given function
|
21
|
+
(def complement
|
22
|
+
(fn (f) (fn (x) (not (f x)))))
|
23
|
+
|
24
|
+
; If a number is even
|
25
|
+
(def even?
|
26
|
+
(fn (x) (= (mod x 2) 0)))
|
27
|
+
|
28
|
+
; If a number is odd
|
29
|
+
(def odd? (complement even?))
|
30
|
+
|
31
|
+
; Length of a list
|
32
|
+
(def len
|
33
|
+
(fn (coll)
|
34
|
+
(if (empty? coll)
|
35
|
+
0
|
36
|
+
(inc (len (tail coll))))))
|
37
|
+
|
38
|
+
; Gets an item in a list by index
|
39
|
+
(def nth
|
40
|
+
(fn (index coll)
|
41
|
+
(if (= 0 index)
|
42
|
+
(head coll)
|
43
|
+
(nth (dec index) (tail coll)))))
|
44
|
+
|
45
|
+
; Last item in list
|
46
|
+
(def last
|
47
|
+
(fn (coll)
|
48
|
+
(nth (dec (len coll)) coll)))
|
49
|
+
|
50
|
+
; Reverses a list
|
51
|
+
(def reverse
|
52
|
+
(fn (coll)
|
53
|
+
(reduce (fn (acc item) (cons item acc)) (list) coll)))
|
54
|
+
|
55
|
+
; Apply f to all items in list
|
56
|
+
(def map
|
57
|
+
(fn (f coll)
|
58
|
+
(if (= nil (head coll))
|
59
|
+
coll
|
60
|
+
(cons
|
61
|
+
(f (head coll))
|
62
|
+
(map f (tail coll))))))
|
63
|
+
|
64
|
+
; Go through a list passing an accumulator and each item of the list through f
|
65
|
+
; f(acc item)
|
66
|
+
(def reduce
|
67
|
+
(fn (f acc coll)
|
68
|
+
(if (empty? coll)
|
69
|
+
acc
|
70
|
+
(reduce f (f acc (head coll)) (tail coll)))))
|
71
|
+
|
72
|
+
; Filter a list of items based on a function
|
73
|
+
(def filter
|
74
|
+
(fn (f coll)
|
75
|
+
(reduce
|
76
|
+
(fn (acc item) (if (f item) (cons item acc) acc))
|
77
|
+
(list)
|
78
|
+
(reverse coll))))
|
79
|
+
|
80
|
+
; Sum of all items in a list
|
81
|
+
(def sum
|
82
|
+
(fn (coll)
|
83
|
+
(reduce + 0 coll)))
|
84
|
+
|
85
|
+
; Take x items from list
|
86
|
+
(def take
|
87
|
+
(fn (num coll)
|
88
|
+
(if (= num 0)
|
89
|
+
(list)
|
90
|
+
(cons (head coll) (take (dec num) (tail coll))))))
|
91
|
+
|
92
|
+
; Drop x items from list
|
93
|
+
(def drop
|
94
|
+
(fn (num coll)
|
95
|
+
(if (= num 0)
|
96
|
+
coll
|
97
|
+
(drop (dec num) (tail coll)))))
|
98
|
+
|
99
|
+
; Exclusive range
|
100
|
+
(def range
|
101
|
+
(fn (from to)
|
102
|
+
(if (= from to)
|
103
|
+
(list)
|
104
|
+
(cons from (range (inc from) to)))))
|
105
|
+
|
106
|
+
; Highest value in list
|
107
|
+
(def max
|
108
|
+
(fn (coll)
|
109
|
+
(reduce
|
110
|
+
(fn (acc item) (if (< acc item) item acc))
|
111
|
+
(head coll)
|
112
|
+
(tail coll))))
|
113
|
+
|
114
|
+
; Lowest value in list
|
115
|
+
(def min
|
116
|
+
(fn (coll)
|
117
|
+
(reduce
|
118
|
+
(fn (acc item) (if (> acc item) item acc))
|
119
|
+
(head coll)
|
120
|
+
(tail coll))))
|
data/lib/lasp/version.rb
CHANGED