qlang 0.0.141 → 0.0.1414

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: 717677209dfcc71bdf36cce50db8ec22692dd7f8
4
- data.tar.gz: 46f9c75f916b1975e03075db0410b64769078ff3
3
+ metadata.gz: 1518e06566b7c7e245e13554112a8181d38bdb1c
4
+ data.tar.gz: eef905e36510038a6f5124264449e485841248df
5
5
  SHA512:
6
- metadata.gz: 22d87e8c71f5e87481488d58fe6fcda5269e983437fb4cdb830b954f4b25942eee41e1be4efdcdbd50d2668f84d0e9c6d49648fb75a4707c946a2e7888949017
7
- data.tar.gz: 675be6320a08b8c72a0950aead7c353cfdebe92b37b08111957e7dee88ecc4c2b22f160bef7bd44b29a1d03547faa191433d19cafc9f5594abc78e2b1cfc4425
6
+ metadata.gz: 7f91e2946d82df754a9bc496f18c494a7014bd4b24c7a14e311d73d7ceb7dc2af9598752d890eb409eea564bcbe75b59d81df727504115b33f9083d6a289e511
7
+ data.tar.gz: f27a4aedfe46515869ec152ad7e0ab9bd64d30b33d95eaa01aaa4201b518405d0b3945ddc9e343dc5a76934058bcaca443ff2d36e4bf0bb3ddb9767a642ab8c7
@@ -0,0 +1,2 @@
1
+ repo_token: ZdXKADwEPNW5PJkIaC76yjqq4w04dIpuZ
2
+ service_name: travis-ci
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ ruby '2.1.2'
4
4
  gem 'dydx', '0.1.412'
5
5
 
6
6
  gem 'rubocop'
7
+ gem 'coveralls', require: false
7
8
  gem 'pry'
8
9
 
9
10
  gemspec
data/README.md CHANGED
@@ -1,42 +1,53 @@
1
1
  # Qlang
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/qlang.svg)](http://badge.fury.io/rb/qlang) [![Build Status](https://travis-ci.org/gogotanaka/Q.svg?branch=master)](https://travis-ci.org/gogotanaka/Q) [![Coverage Status](https://coveralls.io/repos/gogotanaka/Q/badge.png?branch=master)](https://coveralls.io/r/gogotanaka/Q?branch=master) [![Code Climate](https://codeclimate.com/github/gogotanaka/Q/badges/gpa.svg)](https://codeclimate.com/github/gogotanaka/Q) [![Dependency Status](https://gemnasium.com/gogotanaka/Q.svg)](https://gemnasium.com/gogotanaka/Q)
4
+
3
5
  Enjoy MATH with Keyboard.
4
6
 
7
+ ### Differentiate
5
8
 
6
9
  ```
7
- # Differentiate
10
+ d/dx(cos(x))
11
+ => ( - sin( x ) )
8
12
 
9
- Q:-> d/dx(cos(x))
10
- ( - sin( x ) )
13
+ d/dx(log(x))
14
+ => ( 1 / x )
11
15
 
12
- Q:-> d/dx(log(x))
13
- ( 1 / x )
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
- # Integrate
23
+ ```
24
+ S(log(x)dx)[0..1]
25
+ => - oo
20
26
 
21
- Q:-> S(log(x)dx)[0..1]
22
- ( - sin( x ) )
27
+ S(sin(x)dx)[0..pi]
28
+ => 2.0
23
29
 
24
- Q:-> d/dx(log(x))
25
- ( 1 / x )
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
- Q:->(1 2 3; 4 5 6)
36
+
37
+ ```
32
38
  (1 2 3; 4 5 6)
39
+ => (1 2 3; 4 5 6)
33
40
 
34
- Q:-> (1 2 3; 4 5 6) + (1 2 3; 4 5 6)
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
- Q:-> (1 2 3; 4 5 6) * (1 2 3)
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(/\w\(\w( ?, ?\w)*\) ?= ?[^\r\n]+/) { :FUNC }
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 }
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Qlang
2
- VERSION = "0.0.141"
2
+ VERSION = "0.0.1414"
3
3
  end
@@ -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
@@ -1,4 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'qlang'
3
3
  include Qlang
4
+
5
+ require 'coveralls'
6
+ Coveralls.wear!
4
7
  require 'pry'
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.141
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
@@ -1,4 +0,0 @@
1
- loop do
2
- print 'P:-> '
3
- puts eval gets
4
- end