p-lang 0.0.2 → 0.0.3

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.
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  P is a small ('pequena' in portuguese) functional programming language.
4
4
 
5
5
  fib = [1| 1],
6
- [2| 2],
6
+ [2| 1],
7
7
  [n| fib(n-1) + fib(n-2)]
8
8
 
9
9
  fib(10)
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :build:
4
4
  :major: 0
5
5
  :minor: 0
data/lib/vm/proc.rb CHANGED
@@ -13,16 +13,20 @@ class Proc
13
13
  return false
14
14
  end
15
15
  else
16
- form[2].each_with_index do |p, i|
17
- unless p[0] == :id
18
- unless p == obj[2][i]
19
- if p[0] == :object
20
- return compare_form(p, obj[2][i])
21
- else
22
- return false
16
+ if form[2].length == obj[2].length
17
+ form[2].each_with_index do |p, i|
18
+ unless p[0] == :id
19
+ unless p == obj[2][i]
20
+ if p[0] == :object
21
+ return compare_form(p, obj[2][i])
22
+ else
23
+ return false
24
+ end
23
25
  end
24
26
  end
25
27
  end
28
+ else
29
+ return false
26
30
  end
27
31
  end
28
32
  end
@@ -31,11 +35,15 @@ class Proc
31
35
  end
32
36
 
33
37
  def call?(params)
34
- params.each_with_index do |param, i|
35
- unless compare_form(@form[i], param.form)
36
- return false
38
+ if @form.length == params.length
39
+ params.each_with_index do |param, i|
40
+ unless compare_form(@form[i], param.form)
41
+ return false
42
+ end
37
43
  end
44
+ return true
45
+ else
46
+ return false
38
47
  end
39
- return true
40
48
  end
41
- end
49
+ end
data/lib/vm/std/io.rb CHANGED
@@ -10,8 +10,8 @@ module PLang
10
10
  puts value.to_s
11
11
  end
12
12
  end
13
- lamb.form = []
13
+ lamb.form = [nil]
14
14
  [lamb]
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -34,4 +34,5 @@ begin(1,2,3,4)
34
34
  {obj: x} -> f = [x-1] {obj: 1} -> f()
35
35
  {obj: 1, 2, 3, x} -> f = [1+2+3+x] {obj: 1, 2, 3, 10}->f()
36
36
  f = [_,x,_| x*2] f(1,2,3)
37
- f = [{obj: {xxx: _}, x}, y| x+y] f({obj: {xxx: 1}, 2}, 3)
37
+ f = [{obj: {xxx: _}, x}, y| x+y] f({obj: {xxx: 1}, 2}, 3)
38
+ list_sum = [{list: head, tail}| head + list_sum(tail)], [{list}| 0] list_sum({list: 1, {list: 2, {list}}})
@@ -34,4 +34,5 @@ true
34
34
  0
35
35
  16
36
36
  4
37
- 5
37
+ 5
38
+ 3
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: p-lang
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Bonadio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-06 00:00:00 -03:00
18
+ date: 2010-07-07 00:00:00 -03:00
19
19
  default_executable: p-lang
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency