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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fca3af94104dd1dc67d77518aaf7453a42b109d
4
- data.tar.gz: a2a3d7157ec4383687b5cefe14de7d0f643058e5
3
+ metadata.gz: d33419ed01e48e150efc416ec315d24df18ee6b9
4
+ data.tar.gz: 2c9c32ff5dad6abe4fab2f55fdeb0e9ab3cf36b2
5
5
  SHA512:
6
- metadata.gz: 81b9f85741d98c4395246d241fcbe471ee9524247bb297a2fc9b1519494ac0db0ab0622fac4e47256191f756432ec64de867be555afbf4dbb1aef27f5a173eab
7
- data.tar.gz: 54e9ac7f09dbb55fb2bb807df769c4040026cf0d7d2b8a4004182f439cd66c399eaf237344dbd1c68e90d08989b7889c264547dcdea09fdbf7b365269be66dfb
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.sort == args },
8
- :> => -> (*args) { args.sort.reverse == args },
9
- :"=" => -> (*args) { args.uniq.count == 1 },
10
- :list => -> (*args) { args },
11
- :head => -> (list) { list.first },
12
- :tail => -> (list) { list.drop(1) },
13
- :cons => -> (item, list) { [item] + list },
14
- :"hash-map" => -> (*args) { Hash[*args] },
15
- :get => -> (key, a) { a[key] },
16
- :assoc => -> (a, key, val) { a.dup.tap { |a| a[key]=val } },
17
- :dissoc => -> (a, key) { a.dup.tap { |a| a.delete(key) } },
18
- :not => -> (arg) { !arg },
19
- :println => -> (output) { puts output },
20
- :"." => -> (obj, m, *args) { obj.send(m, *args) },
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
@@ -99,7 +99,7 @@
99
99
  ; Exclusive range
100
100
  (def range
101
101
  (fn (from to)
102
- (if (= from to)
102
+ (if (>= from to)
103
103
  (list)
104
104
  (cons from (range (inc from) to)))))
105
105
 
data/lib/lasp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lasp
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
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.5.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: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2016-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler