lasp 0.5.0 → 0.6.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 +6 -0
- data/lib/lasp/corelib.rb +20 -18
- data/lib/lasp/eval.rb +6 -6
- data/lib/lasp/stdlib.lasp +1 -1
- data/lib/lasp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d33419ed01e48e150efc416ec315d24df18ee6b9
|
4
|
+
data.tar.gz: 2c9c32ff5dad6abe4fab2f55fdeb0e9ab3cf36b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c38c3f9008608f4bec13175e7e03fe545e6767d2292fa9f3d75eca7151068c520ffe2e0e4546fc15a438adc409223a369e11b9db43ed3ea386193d8de19cb07
|
7
|
+
data.tar.gz: efd637931a8d72b480384118186df5060e975e1bd1b60afac9e628060631204ddf4005f5cc0f76f93d15b5628030df1024c62130bb8cd8a58f2d4848bd693c5a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Läsp changelog
|
2
2
|
|
3
|
+
## v0.6.0
|
4
|
+
|
5
|
+
- `<` and `>` now return false when given a list of equal items, they all **have to** increase or decrease.
|
6
|
+
- Add `<=` and `>=` to the core library.
|
7
|
+
- Fix stack overflowing when using `range` with an upper bound less than the lower bound, this now returns an empty list.
|
8
|
+
|
3
9
|
## v0.5.0
|
4
10
|
|
5
11
|
- Merge `lasp-repl` command into `lasp`, it starts when not provided with a filename.
|
data/lib/lasp/corelib.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
module Lasp
|
2
2
|
CORELIB = {
|
3
|
-
:+ => -> (*args) { args.reduce(:+)
|
4
|
-
:- => -> (*args) { args.reduce(:-)
|
5
|
-
:* => -> (*args) { args.reduce(:*)
|
6
|
-
:/ => -> (*args) { args.reduce(:/)
|
7
|
-
:< => -> (*args) { args.
|
8
|
-
:> => -> (*args) { args.
|
9
|
-
|
10
|
-
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
3
|
+
:+ => -> (*args) { args.reduce(:+) },
|
4
|
+
:- => -> (*args) { args.reduce(:-) },
|
5
|
+
:* => -> (*args) { args.reduce(:*) },
|
6
|
+
:/ => -> (*args) { args.reduce(:/) },
|
7
|
+
:< => -> (*args) { args.each_cons(2).all? { |a, b| a < b } },
|
8
|
+
:> => -> (*args) { args.each_cons(2).all? { |a, b| a > b } },
|
9
|
+
:<= => -> (*args) { args.each_cons(2).all? { |a, b| a <= b } },
|
10
|
+
:>= => -> (*args) { args.each_cons(2).all? { |a, b| a >= b } },
|
11
|
+
:"=" => -> (*args) { args.uniq.count == 1 },
|
12
|
+
:list => -> (*args) { args },
|
13
|
+
:head => -> (list) { list.first },
|
14
|
+
:tail => -> (list) { list.drop(1) },
|
15
|
+
:cons => -> (item, list) { [item] + list },
|
16
|
+
:"hash-map" => -> (*args) { Hash[*args] },
|
17
|
+
:get => -> (key, a) { a[key] },
|
18
|
+
:assoc => -> (a, key, val) { a.dup.tap { |a| a[key] = val } },
|
19
|
+
:dissoc => -> (a, key) { a.dup.tap { |a| a.delete(key) } },
|
20
|
+
:not => -> (arg) { !arg },
|
21
|
+
:println => -> (output) { puts output },
|
22
|
+
:"." => -> (obj, m, *args) { obj.send(m, *args) },
|
21
23
|
}
|
22
24
|
end
|
data/lib/lasp/eval.rb
CHANGED
@@ -17,20 +17,20 @@ module Lasp
|
|
17
17
|
|
18
18
|
if head == :def
|
19
19
|
key, value = tail
|
20
|
-
env[key] = eval(value, env)
|
20
|
+
env[key] = Lasp::eval(value, env)
|
21
21
|
elsif head == :fn
|
22
22
|
params, func = tail
|
23
|
-
-> (*args) { eval(func, env.merge(Hash[params.zip(args)])) }
|
23
|
+
-> (*args) { Lasp::eval(func, env.merge(Hash[params.zip(args)])) }
|
24
24
|
elsif head == :do
|
25
|
-
tail.map { |form| eval(form, env) }.last
|
25
|
+
tail.map { |form| Lasp::eval(form, env) }.last
|
26
26
|
elsif head == :if
|
27
27
|
conditional, true_form, false_form = tail
|
28
|
-
eval(conditional, env) ? eval(true_form, env) : eval(false_form, env)
|
28
|
+
Lasp::eval(conditional, env) ? Lasp::eval(true_form, env) : Lasp::eval(false_form, env)
|
29
29
|
elsif Proc === head
|
30
30
|
head.(*tail)
|
31
31
|
else
|
32
|
-
fn = eval(head, env)
|
33
|
-
fn.(*tail.map { |form| eval(form, env) })
|
32
|
+
fn = Lasp::eval(head, env)
|
33
|
+
fn.(*tail.map { |form| Lasp::eval(form, env) })
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/lasp/stdlib.lasp
CHANGED
data/lib/lasp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lasp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Börjesson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|