qlang 0.0.141 → 0.0.1414
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/Gemfile +1 -0
- data/README.md +30 -19
- data/lib/qlang/lexer/wrap_lexer.rb +2 -1
- data/lib/qlang/parser.rb +4 -0
- data/lib/qlang/version.rb +1 -1
- data/spec/iq_spec.rb +2 -0
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
- data/tanaka.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1518e06566b7c7e245e13554112a8181d38bdb1c
|
4
|
+
data.tar.gz: eef905e36510038a6f5124264449e485841248df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f91e2946d82df754a9bc496f18c494a7014bd4b24c7a14e311d73d7ceb7dc2af9598752d890eb409eea564bcbe75b59d81df727504115b33f9083d6a289e511
|
7
|
+
data.tar.gz: f27a4aedfe46515869ec152ad7e0ab9bd64d30b33d95eaa01aaa4201b518405d0b3945ddc9e343dc5a76934058bcaca443ff2d36e4bf0bb3ddb9767a642ab8c7
|
data/.coveralls.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,42 +1,53 @@
|
|
1
1
|
# Qlang
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/qlang) [](https://travis-ci.org/gogotanaka/Q) [](https://coveralls.io/r/gogotanaka/Q?branch=master) [](https://codeclimate.com/github/gogotanaka/Q) [](https://gemnasium.com/gogotanaka/Q)
|
4
|
+
|
3
5
|
Enjoy MATH with Keyboard.
|
4
6
|
|
7
|
+
### Differentiate
|
5
8
|
|
6
9
|
```
|
7
|
-
|
10
|
+
d/dx(cos(x))
|
11
|
+
=> ( - sin( x ) )
|
8
12
|
|
9
|
-
|
10
|
-
(
|
13
|
+
d/dx(log(x))
|
14
|
+
=> ( 1 / x )
|
11
15
|
|
12
|
-
|
13
|
-
(
|
16
|
+
d/dy(y ** 2)
|
17
|
+
=> ( 2 * y )
|
18
|
+
```
|
14
19
|
|
15
|
-
Q:-> d/dy(y ** 2)
|
16
|
-
( 2 * y )
|
17
20
|
|
21
|
+
### Integrate
|
18
22
|
|
19
|
-
|
23
|
+
```
|
24
|
+
S(log(x)dx)[0..1]
|
25
|
+
=> - oo
|
20
26
|
|
21
|
-
|
22
|
-
|
27
|
+
S(sin(x)dx)[0..pi]
|
28
|
+
=> 2.0
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
S(cos(x)dx)[0..pi]
|
31
|
+
=> 0.0
|
32
|
+
```
|
26
33
|
|
27
|
-
Q:-> d/dy(y ** 2)
|
28
|
-
( 2 * y )
|
29
34
|
|
30
35
|
### Matrix
|
31
|
-
|
36
|
+
|
37
|
+
```
|
32
38
|
(1 2 3; 4 5 6)
|
39
|
+
=> (1 2 3; 4 5 6)
|
33
40
|
|
34
|
-
|
35
|
-
(2 4 6; 8 10 12)
|
41
|
+
(1 2 3; 4 5 6) + (1 2 3; 4 5 6)
|
42
|
+
=> (2 4 6; 8 10 12)
|
36
43
|
|
37
|
-
|
38
|
-
(14 32)
|
44
|
+
(1 2 3; 4 5 6) * (1 2 3)
|
45
|
+
=> (14 32)
|
46
|
+
```
|
39
47
|
|
48
|
+
### Function
|
49
|
+
```
|
50
|
+
f(x, y) = x + y
|
40
51
|
```
|
41
52
|
|
42
53
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Qlang
|
2
2
|
module Lexer
|
3
3
|
class WrapLexer < Base
|
4
|
-
rule(
|
4
|
+
rule(/[fgh]\(\w( ?, ?\w)*\) ?= ?[^\r\n]+/) { :FUNC }
|
5
|
+
rule(/[fgh]\( ?\d( *, *\d)* *\)/) { :EFUNC }
|
5
6
|
rule(/S *\(.+\)\[.+\]/) { :ITGL }
|
6
7
|
rule(/\(/) { :LPRN }
|
7
8
|
rule(/\)/) { :RPRN }
|
data/lib/qlang/parser.rb
CHANGED
@@ -61,6 +61,10 @@ module Qlang
|
|
61
61
|
lexed.ch_value(cont_token_with_num, cont)
|
62
62
|
lexed.ch_token(cont_token_with_num, :R)
|
63
63
|
|
64
|
+
when /:EFUNC\d/
|
65
|
+
cont_token_with_num = $&
|
66
|
+
cont = lexed.get_value(cont_token_with_num)
|
67
|
+
lexed.squash_with_prn(cont_token_with_num, cont)
|
64
68
|
when /:CONT\d/
|
65
69
|
lexed.ch_token($&, :R)
|
66
70
|
end
|
data/lib/qlang/version.rb
CHANGED
data/spec/iq_spec.rb
CHANGED
@@ -48,7 +48,9 @@ describe Qlang do
|
|
48
48
|
describe 'Function' do
|
49
49
|
it do
|
50
50
|
expect(Iq.execute('f(x, y) = x + y')).to eq(f(x, y) <= x + y)
|
51
|
+
expect(Iq.execute('f( 4, 5 )')).to eq(9)
|
51
52
|
expect(Iq.execute('g(x) = x ** 2')).to eq(g(x) <= x ** 2)
|
53
|
+
expect(Iq.execute('g(2)')).to eq(4)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qlang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1414
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gogotanaka
|
@@ -74,6 +74,7 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".coveralls.yml"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".rubocop.yml"
|
@@ -114,7 +115,6 @@ files:
|
|
114
115
|
- spec/q_lang_spec.rb
|
115
116
|
- spec/spec_helper.rb
|
116
117
|
- spec/vector_spec.rb
|
117
|
-
- tanaka.rb
|
118
118
|
homepage: http://q-language.org/
|
119
119
|
licenses:
|
120
120
|
- MIT
|
data/tanaka.rb
DELETED