s_calc 0.1.2 → 0.1.4

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +259 -0
  3. data/bin/calc +14 -6
  4. data/lib/calc/calc.rb +278 -148
  5. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71e6238052352f288d04dd872eccba4f61fe316b2a350e9170f49068319ce534
4
- data.tar.gz: 28d214b0aa8762938797b309cd2718065e0de072c9207b94f223e9a0c805c282
3
+ metadata.gz: 71bbe1e1641fd9021338663ad0132482fcb95420895e9188faafb9de9cf612b3
4
+ data.tar.gz: 506bd735892ca62beb09a554488318c2142f831d84fdce3013b5c3591a3d6dd8
5
5
  SHA512:
6
- metadata.gz: f25daea5118727a36f0e5a12d1c73c54d882f15e613345d7dd669143de68e7dc2c226c369eb977ab98b93439d218460135719334af16f2268ebc6487c7e0e0e2
7
- data.tar.gz: 21ee599c61b51656237c8056065460b67de6ccd546c9d68a584bda1b428656e43ca696ed2023a326fcf7a7b8bd88bfe003bcb358439afbe9128743fac02bec1c
6
+ metadata.gz: 2ebefdecfa7fd99ce1a3726ebe89dda31f1eadf27c72180fc182baad1f109029382d63faedcd422d630e8e7d8aff4714faea63451beae9d652822642f57e9f8e
7
+ data.tar.gz: 53bd32713d1c421847f28e47ae883ad650f6a301910c174b624a03017002a79f9fcffe45c7a9e33f8731b151d729c0dcc58fe9467d83a2ea5714264dc48bc39a
data/README.md ADDED
@@ -0,0 +1,259 @@
1
+ 日本語の解説が後半にあります。
2
+
3
+ ### What is this program?
4
+
5
+ The program 'calc' is a scientific calculator written in Ruby programming language.
6
+ It is run from the command line like this.
7
+
8
+ ```
9
+ $ calc 2*3+4*5
10
+ 26
11
+ $ calc
12
+ calc > 0.1-0.2
13
+ -0.1
14
+ calc > sin(PI/6)
15
+ 0.49999999999999994 # Float always includes error.
16
+ calc > quit
17
+ $
18
+ ```
19
+
20
+ ### Prerequisites
21
+
22
+ - Linux OS
23
+ - Ruby 3.1.2 or later (maybe older version is also OK)
24
+
25
+ ### installation
26
+
27
+ There are two ways.
28
+
29
+ 1. Click the 'Code' button, then click 'Download ZIP' in the small dialog.
30
+ 2. Unzip the downloaded Zip file, then a new directory 'calc' will be created.
31
+ 3. Type `gem build s_calc` under the directory 'calc', then the gem file `s_calc-X.X.X.gem` is created.
32
+ The part `X.X.X` is a version number like `0.1.4`.
33
+ 4. Type `gem install s_calc-X.X.X.gem`.
34
+
35
+ Another way is simpler.
36
+ This gem is published to RubyGems.org.
37
+ You can install it from RubyGems.
38
+ Just type:
39
+
40
+ ```
41
+ $ gem install s_calc
42
+ ```
43
+
44
+ Be careful.
45
+ The command name and GitHub repository name is `calc` but the gem name is `s_calc`.
46
+ This is because the name `calc` has already existed in RubyGems.org.
47
+
48
+ ### How to use the program.
49
+
50
+ 1. Start the terminal and type `calc`.
51
+ 2. Then the prompt appears `calc > `
52
+ 3. Type an expression like `2+3` and push Enter key, then the answer `5` appears.
53
+ 4. Type `quit`, `q` or `exit`, then the program will finish.
54
+ 5. You can also use it as a one line calculator like `$ calc "10*20+30"`.
55
+
56
+ ### feature
57
+
58
+ - Operatores: `+`, `-`, `*`, `/`, `**`(power), `-`(unary minus), `(` and `)`
59
+ - Functions: `sqrt`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `exp`, `ln`, `log`, `abs`, `fact`, `floor`, `ceil` and `round`.
60
+ - The special variable `v` keeps the result of the previous calculation.
61
+ - Variable can be used.
62
+ It is a string of alphabets without the keywords above.
63
+ It can be used in any place in the expression.
64
+ `variable_name = expression` is the syntax to define the variable.
65
+ A defined variable can be used in an expression.
66
+
67
+ ### Functions
68
+
69
+ - `sqrt`: Square root. `sqrt(4) => 2`
70
+ - `sin`: `sin(PI) => 1.2246467991473532e-16` It is well known that sin(PI) is zero. But Float always includes error.
71
+ - `cos`: `cos(PI) => -1`
72
+ - `tan`: `tan(PI/4) => 0.9999999999999999` The answer includes error. The exact value is 1.
73
+ - `asin`: Inverse of the sine function. `asin(1) => 1.5707963267948966` This is PI/2
74
+ - `acos`: Inverse of the cosine function. `acos(1) => 0`
75
+ - `atan`: Inverse of the tangent function. `atan(1) => 0.7853981633974483` This is PI/4
76
+ - `exp`: Exponential function. `exp(n)` means `e` raised to the power of n. `exp(1) => 2.718281828459045` It is E.
77
+ - `ln`: Natural logarithm. `ln(E) => 1`
78
+ - `log`: Common logarithm or decimal logarithm. The base is 10. `log(10) => 1`
79
+ - `abs`: Absolute value. `abs(-10) =>10`
80
+ - `fact`: Factorial. `fact(10) => 3628800` The argument must be non-negative. If it isn't an integer, it will be rounded down to an integer. It must be less than 171 because of the limitation of Float.
81
+ - `floor`: Floor function. `floor(3.45) => 3`
82
+ - `ceil`: Ceiling function. `ceil(3.45) => 4`
83
+ - `round`: Rounding function. `round(3.45,1) => 3.5, round(-3.45,1) => -3.5` The rounding is done away from zero if the argument is at the middle of two candidates.
84
+
85
+ ### Racc library
86
+
87
+ Racc is a Ruby standard library.
88
+ It is a parser generator like Yacc, which is a famous parser generator made for the Unix Operating system.
89
+ Calc uses Racc.
90
+ It makes the library file `lib/calc/calc.rb` with Racc.
91
+ The source file is `racc/calc.y`.
92
+ You can compile it by typing:
93
+
94
+ ```
95
+ $ rake
96
+ ```
97
+
98
+ See `racc/doc.md` for details.
99
+
100
+ ### Rakefile
101
+
102
+ You can do the following
103
+
104
+ - `rake`: Compile `racc/calc.y` and create/update `lib/calc/calc.rb`.
105
+ - `rake rdoc`: Create documents under `docs` directory.
106
+ - `rake test`: Run test programs under `test` directory.
107
+
108
+ ### Using Calc as a library
109
+
110
+ You can use Calc as a library in your Ruby program.
111
+
112
+ - First, require 'calc'.
113
+ - Create an instance of the class `Calc`. Let the instance name be 'c'.
114
+ - Call `c.run(s)` where `s` is a string of an expression. Then it returns the value of the expression.
115
+ For example, `c.run("1+2")` returns 3.0.
116
+
117
+ The following is a sample code.
118
+
119
+ ```ruby
120
+ require 'calc'
121
+
122
+ c = Calc.new
123
+ s = "1+2"
124
+ print "#{c.run(s)}\n" #=> 3.0
125
+ ```
126
+
127
+ ### License
128
+
129
+ GPL ver 3 or later.
130
+ See [License.md](License.md) for details.
131
+
132
+ ### これは何のプログラム?
133
+
134
+ Rubyプログラム`calc.rb`は関数電卓です。
135
+ コマンドラインから次のように起動できます。
136
+
137
+ ```
138
+ $ calc 2*3+4*5
139
+ 26
140
+ $ calc
141
+ calc > 0.1-0.2
142
+ -0.1
143
+ calc > sin(PI/6)
144
+ 0.49999999999999994 # 実数計算では誤差が発生します
145
+ calc > quit
146
+ $
147
+ ```
148
+
149
+ ### 動作条件
150
+
151
+ - Linux OS
152
+ - Ruby バージョン3.1.2以降(おそらく不利バージョンでも動作します)
153
+
154
+ ### インストール
155
+
156
+ 2通りのインストール方法があります。
157
+
158
+ 1. 'Code'ボタンをクリックし、現れた小さなダイアログの'Download ZIP'をクリックする
159
+ 2. ダウンロードしたZipファイルを解凍する。これにより新しく「calc」ディレクトリが作られ、その中にすべてのファイルが収められる
160
+ 3. 「gem build s_calc」を実行することにより、gemファイル「s_calc-X.X.X.gem」が作られる。「X.X.X」の部分はバージョン番号で、例えば「0.1.4」のような数字である
161
+ 4. 「gem install s_calc-X.X.X.gem」とタイプし、gemをインストールする
162
+
163
+ もっと簡単なインストール方法は、RubyGemsからインストールすることです。
164
+ 次のようにタイプするだけでgemをダウンロードしインストールします。
165
+
166
+ ```
167
+ $ gem install s_calc
168
+ ```
169
+
170
+ コマンド名とGitHubのレポジトリ名が`calc`であるのに対して、gem名は`s_calc`であることに注意してください。
171
+ これは、RubyGemsには既に`calc`という名前のgemが存在しており、異なるgem名が必要だったためです。
172
+
173
+ ### 使い方
174
+
175
+ 1. 解凍したフォルダで端末(コマンドライン)を起動し、「calc」と入力する
176
+ 2. プロンプト「calc >」が現れる
177
+ 3. 式(例えば2+3)と入力し、エンターキーを押すと、答え「5」が表示される
178
+ 4. 「quit」または「q」または「exit」とタイプするとプログラムは終了する
179
+ 5. 引数を付けて一行計算アプリとしても使える。(例)`$ calc "10*20+30"`
180
+
181
+ ### 特長
182
+
183
+ - 次の演算記号が使える。`+`, `-`, `*`, `/`, `**`(累乗), `-`(単項マイナス), `(`, `)`
184
+ - 関数: `sqrt`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `exp`, `ln`, `log`, `abs`, `fact`, `floor`, `ceil` and `round`.
185
+ - 変数が使える
186
+ - calcは直前の計算結果を記憶しており、変数`v` でその値を参照できる
187
+ - 変数はアルファベットからなる文字列で、上記のキーワードを除く。
188
+ `変数名 = 式` により、変数に値を代入することができる。
189
+ 定義された変数は、式の中で使うことができる
190
+
191
+ ### 関数
192
+
193
+ - `sqrt`: 平方根。 `sqrt(4) => 2`
194
+ - `sin`: `sin(PI) => 1.2246467991473532e-16` sin(PI)はゼロですが、浮動小数点の計算は常に誤差が生じます
195
+ - `cos`: `cos(PI) => -1`
196
+ - `tan`: `tan(PI/4) => 0.9999999999999999` 答えは誤差を含んでいます。正確には1になります
197
+ - `asin`: サインの逆三角関数。`asin(1) => 1.5707963267948966` これはPI/2です
198
+ - `acos`: コサインの逆三角関数。`acos(1) => 0`
199
+ - `atan`: タンジェントの逆三角関数。`atan(1) => 0.7853981633974483` これはPI/4です
200
+ - `exp`: 指数関数。 `exp(n)`は`e`のn乗。`exp(1) => 2.718281828459045` これはEです
201
+ - `ln`: 自然対数。底がeの対数。`ln(E) => 1`
202
+ - `log`: 常用対数。底が10の対数。`log(10) => 1`
203
+ - `abs`: 絶対値。`abs(-10) =>10`
204
+ - `fact`: 階乗。`fact(10) => 3628800` 引数はゼロ以上。引数が整数でなければ、切り捨てて整数に直す。引数は171より小さくなければならない。答えがFloatの最大値を越えないように制限するため。
205
+ - `floor`: フロアー関数。小数点以下を切り捨て。`floor(3.45) => 3`
206
+ - `ceil`: シーリング関数。小数点以下を切り上げ。`ceil(3.45) => 4`
207
+ - `round`: 四捨五入関数。`round(3.45,1) => 3.5, round(-3.45,1) => -3.5` 丸める桁が5である場合は、ゼロから遠い方に丸める。
208
+
209
+ ### Racc
210
+
211
+ RaccはRubyの標準ライブラリーです。
212
+ パーサー・ジェネレーターと呼ばれ、Unixオペレーティングシステム上の有名なYaccに似ています。
213
+ CalcはRaccを使って`lib/calc/calc.rb`を生成しています。
214
+ そのソース・ファイルは`racc/calc.y`です。
215
+ コンパイルは次のようにタイプするだけでできます。
216
+
217
+ ```
218
+ $ rake
219
+ ```
220
+
221
+ ドキュメント `racc/doc.md`を参照してください。
222
+
223
+ ### Rakefile
224
+
225
+ 次のことができます。
226
+
227
+ - `rake`: `racc/calc.y`をコンパイルして`lib/calc/calc.rb`を生成する
228
+ - `rake rdoc`: `docs`ディレクトリ以下にドキュメントを生成する
229
+ - `rake test`: `test`ディレクトリの下にあるテストプログラムを実行する
230
+
231
+ ### Calcをライブラリとして使う
232
+
233
+ CalcをライブラリとしてRubyプログラムの中で使うことができます。
234
+
235
+ - まず、'calc'をrequireする
236
+ - `Calc`クラスのインスタンスを生成する。仮にその名前を`c`とする
237
+ - 数式を表す文字列を`s`とすると、`c.run(s)`はその数式を計算した値を返す
238
+ 例えば、`c.run("1+2")`は3.0を返す。
239
+
240
+ 以下に簡単なサンプルコードを示します。
241
+
242
+ ```ruby
243
+ require 'calc'
244
+
245
+ c = Calc.new
246
+ s = "1+2"
247
+ print "#{c.run(s)}\n" #=> 3.0
248
+ ```
249
+
250
+ ### ライセンス
251
+
252
+ Copyright (C) 2022,2023 ToshioCP (関谷 敏雄)
253
+
254
+ このプログラムは、フリーソフトウェア財団によって発行された「GNU一般公衆利用許諾書」(バージョン3か、希望によってはそれ以降のバージョンのうちどれか)の定める条件の下で再頒布または改変することができる。
255
+
256
+ このプログラムは有用であることを願って頒布されますが、*全くの無保証* です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含め全く存在しません。
257
+ 詳しくは[GNU 一般公衆利用許諾書(英語)](https://www.gnu.org/licenses/gpl-3.0.en.html)、またはその日本語訳[GNU 一般公衆利用許諾書の日本語訳](https://gpl.mhatta.org/gpl.ja.html)をご覧ください。
258
+
259
+ なお、ライセンスを英語で記した[License.md](License.md)もあります。
data/bin/calc CHANGED
@@ -11,8 +11,14 @@ end
11
11
  def usage_possible_calculation
12
12
  $stderr.print "Possible calculation:\n"
13
13
  $stderr.print " Arithmetic such as +, -, *, /, (, ), - (unary minus) and ** (power).\n"
14
- $stderr.print " Functions such as sqrt, sin, cos, tan, asin, acos, atan, exp, log and log10.\n"
14
+ $stderr.print " Functions such as sqrt, sin, cos, tan, asin, acos, atan, exp, ln, log,\n"
15
+ $stderr.print " abs, fact, floor, ceil and round\n"
15
16
  $stderr.print " Variables (any alphabetical word) and the special variable 'v' that is the former result.\n"
17
+ $stderr.print "Example:\n"
18
+ $stderr.print " sin(PI/2) #=> 1\n"
19
+ $stderr.print " ln(E) #=> 1\n"
20
+ $stderr.print " log(10) #=> 1\n"
21
+ $stderr.print " round(1.25, 1) #=> 1.3, round(1.5,0) #=> 2, round(-1.5,0) #=> -2\n"
16
22
  end
17
23
 
18
24
  calc = Calc.new
@@ -20,9 +26,10 @@ if ARGV[0] =~ /--help|-h/
20
26
  usage
21
27
  elsif ARGV.size == 1
22
28
  begin
23
- print "#{calc.run(ARGV[0])}\n"
29
+ a = calc.run(ARGV[0])
30
+ print "#{a == a.to_i ? a.to_i : a}\n"
24
31
  rescue StandardError => evar
25
- print "#{evar.message[1..-1]}\n" # remove the newline at the beginning of the message
32
+ print "#{evar.message}\n"
26
33
  end
27
34
  else
28
35
  while buf = Readline.readline("calc > ", true)
@@ -32,9 +39,10 @@ else
32
39
  usage_possible_calculation
33
40
  else
34
41
  begin
35
- print "#{calc.run(buf)}\n"
36
- rescue => evar
37
- print "#{evar.message[1..-1]}\n" # remove the newline at the beginning of the message
42
+ a = calc.run(buf)
43
+ print "#{a == a.to_i ? a.to_i : a}\n"
44
+ rescue StandardError =>evar
45
+ print "#{evar.message}\n"
38
46
  end
39
47
  end
40
48
  end
data/lib/calc/calc.rb CHANGED
@@ -12,7 +12,7 @@ include Math
12
12
 
13
13
  class Calc < Racc::Parser
14
14
 
15
- module_eval(<<'...end calc.y/module_eval...', 'calc.y', 45)
15
+ module_eval(<<'...end calc.y/module_eval...', 'calc.y', 50)
16
16
 
17
17
  def initialize
18
18
  @table = {}
@@ -27,7 +27,7 @@ end
27
27
  def lex(s)
28
28
  ss = StringScanner.new(s)
29
29
  until ss.eos?
30
- if ss.scan(/sqrt|sin|cos|tan|asin|acos|atan|exp|log|sqrt|PI|E|v/)
30
+ if ss.scan(/sqrt|sin|cos|tan|asin|acos|atan|exp|ln|log|abs|fact|floor|ceil|round|PI|E|v/)
31
31
  @tokens << [ss[0].to_sym, ss[0]]
32
32
  elsif ss.scan(/[[:alpha:]]+/)
33
33
  @tokens << [:ID, ss[0]]
@@ -35,7 +35,7 @@ def lex(s)
35
35
  @tokens << [:NUM, ss[0].to_f]
36
36
  elsif ss.scan(/\*\*/)
37
37
  @tokens << [:POWER,ss[0]]
38
- elsif ss.scan(/[+\-*\/()=;]/)
38
+ elsif ss.scan(/[+\-*\/()=;,]/)
39
39
  @tokens << [ss[0],ss[0]]
40
40
  elsif ss.scan(/\s+/)
41
41
  # ignore spaces
@@ -50,130 +50,213 @@ def next_token
50
50
  @tokens.shift
51
51
  end
52
52
 
53
+ def fact(f)
54
+ n = f.to_i
55
+ raise ("No factorial for negative number.") if n < 0
56
+ raise ("The argument of fact must be less than 171.") if n >= 171
57
+ if n == 0 || n == 1
58
+ 1.0
59
+ else
60
+ (1..n).inject{|result, item| result*item}.to_f
61
+ end
62
+ end
63
+
53
64
  ...end calc.y/module_eval...
54
65
  ##### State transition tables begin ###
55
66
 
56
67
  racc_action_table = [
57
- 24, 25, 22, 23, 24, 25, 22, 23, 24, 25,
58
- 22, 23, 24, 25, 22, 23, 24, 25, 22, 23,
59
- 21, 48, 24, 25, 26, 59, 24, 25, 29, 60,
60
- 31, 32, 33, 61, 34, 35, 36, 62, 24, 25,
61
- 22, 23, 24, 25, 22, 23, 24, 25, 22, 23,
62
- 24, 25, 22, 23, 24, 25, 22, 23, 37, 63,
63
- 38, 39, 40, 64, 41, 29, 29, 65, nil, nil,
64
- nil, 66, nil, nil, nil, 67, 24, 25, 22, 23,
65
- nil, 4, 3, 7, 8, 9, 10, 11, 12, 13,
66
- 14, 15, 16, 17, 18, 19, 20, 68, 6, 4,
67
- 28, 7, 8, 9, 10, 11, 12, 13, 14, 15,
68
- 16, 17, 18, 19, 20, nil, 6, 4, 28, 7,
68
+ 29, 30, 27, 28, 29, 30, 27, 28, 29, 30,
69
+ 27, 28, 29, 30, 27, 28, 29, 30, 27, 28,
70
+ 29, 30, 27, 28, 29, 30, 26, 88, 29, 30,
71
+ 58, 31, 34, 36, 74, 37, 38, 39, 75, 40,
72
+ 41, 42, 76, 43, 44, 45, 77, 29, 30, 27,
73
+ 28, 29, 30, 27, 28, 29, 30, 27, 28, 29,
74
+ 30, 27, 28, 29, 30, 27, 28, 29, 30, 27,
75
+ 28, 46, 47, 78, 48, 49, 50, 79, 51, 34,
76
+ 34, 80, nil, nil, nil, 81, nil, nil, nil, 82,
77
+ nil, nil, nil, 83, 29, 30, 27, 28, 29, 30,
78
+ 27, 28, 29, 30, 27, 28, 29, 30, 27, 28,
79
+ 29, 30, 27, 28, 29, 30, 27, 28, nil, nil,
80
+ 84, nil, nil, nil, 85, nil, nil, nil, 86, nil,
81
+ nil, nil, 87, nil, nil, nil, 90, 4, 3, 7,
69
82
  8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
70
- 18, 19, 20, nil, 6, 4, 28, 7, 8, 9,
83
+ 18, 19, 20, 21, 22, 23, 24, 25, nil, 6,
84
+ 4, 33, 7, 8, 9, 10, 11, 12, 13, 14,
85
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
86
+ 25, nil, 6, 4, 33, 7, 8, 9, 10, 11,
87
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
88
+ 22, 23, 24, 25, nil, 6, 4, 33, 7, 8,
89
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
90
+ 19, 20, 21, 22, 23, 24, 25, nil, 6, 4,
91
+ 33, 7, 8, 9, 10, 11, 12, 13, 14, 15,
92
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
93
+ nil, 6, 4, 33, 7, 8, 9, 10, 11, 12,
94
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
95
+ 23, 24, 25, nil, 6, 4, 33, 7, 8, 9,
71
96
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
72
- 20, nil, 6, 4, 28, 7, 8, 9, 10, 11,
73
- 12, 13, 14, 15, 16, 17, 18, 19, 20, nil,
74
- 6, 4, 28, 7, 8, 9, 10, 11, 12, 13,
75
- 14, 15, 16, 17, 18, 19, 20, nil, 6, 4,
76
- 28, 7, 8, 9, 10, 11, 12, 13, 14, 15,
77
- 16, 17, 18, 19, 20, nil, 6, 4, 28, 7,
97
+ 20, 21, 22, 23, 24, 25, nil, 6, 4, 33,
98
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
99
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, nil,
100
+ 6, 4, 33, 7, 8, 9, 10, 11, 12, 13,
101
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
102
+ 24, 25, nil, 6, 4, 33, 7, 8, 9, 10,
103
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
104
+ 21, 22, 23, 24, 25, nil, 6, 4, 33, 7,
78
105
  8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
79
- 18, 19, 20, nil, 6, 4, 28, 7, 8, 9,
106
+ 18, 19, 20, 21, 22, 23, 24, 25, nil, 6,
107
+ 4, 33, 7, 8, 9, 10, 11, 12, 13, 14,
108
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
109
+ 25, nil, 6, 4, 33, 7, 8, 9, 10, 11,
110
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
111
+ 22, 23, 24, 25, nil, 6, 4, 33, 7, 8,
112
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
113
+ 19, 20, 21, 22, 23, 24, 25, nil, 6, 4,
114
+ 33, 7, 8, 9, 10, 11, 12, 13, 14, 15,
115
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
116
+ nil, 6, 4, 33, 7, 8, 9, 10, 11, 12,
117
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
118
+ 23, 24, 25, nil, 6, 4, 33, 7, 8, 9,
80
119
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
81
- 20, nil, 6, 4, 28, 7, 8, 9, 10, 11,
82
- 12, 13, 14, 15, 16, 17, 18, 19, 20, nil,
83
- 6, 4, 28, 7, 8, 9, 10, 11, 12, 13,
84
- 14, 15, 16, 17, 18, 19, 20, nil, 6, 4,
85
- 28, 7, 8, 9, 10, 11, 12, 13, 14, 15,
86
- 16, 17, 18, 19, 20, nil, 6, 4, 28, 7,
120
+ 20, 21, 22, 23, 24, 25, nil, 6, 4, 33,
121
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
122
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, nil,
123
+ 6, 4, 33, 7, 8, 9, 10, 11, 12, 13,
124
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
125
+ 24, 25, nil, 6, 4, 33, 7, 8, 9, 10,
126
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
127
+ 21, 22, 23, 24, 25, nil, 6, 4, 33, 7,
87
128
  8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
88
- 18, 19, 20, nil, 6, 4, 28, 7, 8, 9,
129
+ 18, 19, 20, 21, 22, 23, 24, 25, nil, 6,
130
+ 4, 33, 7, 8, 9, 10, 11, 12, 13, 14,
131
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
132
+ 25, nil, 6, 4, 33, 7, 8, 9, 10, 11,
133
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
134
+ 22, 23, 24, 25, nil, 6, 33, 7, 8, 9,
89
135
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
90
- 20, nil, 6, 4, 28, 7, 8, 9, 10, 11,
91
- 12, 13, 14, 15, 16, 17, 18, 19, 20, nil,
92
- 6, 4, 28, 7, 8, 9, 10, 11, 12, 13,
93
- 14, 15, 16, 17, 18, 19, 20, nil, 6, 4,
94
- 28, 7, 8, 9, 10, 11, 12, 13, 14, 15,
95
- 16, 17, 18, 19, 20, nil, 6, 28, 7, 8,
96
- 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
97
- 19, 20, nil, 6, 28, 7, 8, 9, 10, 11,
98
- 12, 13, 14, 15, 16, 17, 18, 19, 20, nil,
99
- 6, 24, 25, 22, 23, 24, 25, 22, 23 ]
136
+ 20, 21, 22, 23, 24, 25, nil, 6, 33, 7,
137
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
138
+ 18, 19, 20, 21, 22, 23, 24, 25, nil, 6,
139
+ 29, 30, 27, 28 ]
100
140
 
101
141
  racc_action_check = [
102
- 30, 30, 30, 30, 49, 49, 49, 49, 50, 50,
103
- 50, 50, 51, 51, 51, 51, 52, 52, 52, 52,
104
- 1, 30, 42, 42, 3, 49, 43, 43, 5, 50,
105
- 10, 11, 12, 51, 13, 14, 15, 52, 53, 53,
106
- 53, 53, 54, 54, 54, 54, 55, 55, 55, 55,
107
- 56, 56, 56, 56, 57, 57, 57, 57, 16, 53,
108
- 17, 18, 19, 54, 21, 27, 47, 55, nil, nil,
109
- nil, 56, nil, nil, nil, 57, 58, 58, 58, 58,
110
- nil, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111
- 0, 0, 0, 0, 0, 0, 0, 58, 0, 6,
142
+ 73, 73, 73, 73, 35, 35, 35, 35, 59, 59,
143
+ 59, 59, 60, 60, 60, 60, 61, 61, 61, 61,
144
+ 62, 62, 62, 62, 52, 52, 1, 73, 53, 53,
145
+ 35, 3, 5, 10, 59, 11, 12, 13, 60, 14,
146
+ 15, 16, 61, 17, 18, 19, 62, 63, 63, 63,
147
+ 63, 64, 64, 64, 64, 65, 65, 65, 65, 66,
148
+ 66, 66, 66, 67, 67, 67, 67, 68, 68, 68,
149
+ 68, 20, 21, 63, 22, 23, 24, 64, 26, 32,
150
+ 57, 65, nil, nil, nil, 66, nil, nil, nil, 67,
151
+ nil, nil, nil, 68, 69, 69, 69, 69, 70, 70,
152
+ 70, 70, 71, 71, 71, 71, 72, 72, 72, 72,
153
+ 89, 89, 89, 89, 2, 2, 2, 2, nil, nil,
154
+ 69, nil, nil, nil, 70, nil, nil, nil, 71, nil,
155
+ nil, nil, 72, nil, nil, nil, 89, 0, 0, 0,
156
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157
+ 0, 0, 0, 0, 0, 0, 0, 0, nil, 0,
158
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
112
159
  6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
113
- 6, 6, 6, 6, 6, nil, 6, 22, 22, 22,
114
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
115
- 22, 22, 22, nil, 22, 23, 23, 23, 23, 23,
116
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
117
- 23, nil, 23, 24, 24, 24, 24, 24, 24, 24,
118
- 24, 24, 24, 24, 24, 24, 24, 24, 24, nil,
119
- 24, 25, 25, 25, 25, 25, 25, 25, 25, 25,
120
- 25, 25, 25, 25, 25, 25, 25, nil, 25, 26,
121
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
122
- 26, 26, 26, 26, 26, nil, 26, 31, 31, 31,
160
+ 6, nil, 6, 27, 27, 27, 27, 27, 27, 27,
161
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
162
+ 27, 27, 27, 27, nil, 27, 28, 28, 28, 28,
163
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
164
+ 28, 28, 28, 28, 28, 28, 28, nil, 28, 29,
165
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
166
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
167
+ nil, 29, 30, 30, 30, 30, 30, 30, 30, 30,
168
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
169
+ 30, 30, 30, nil, 30, 31, 31, 31, 31, 31,
123
170
  31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
124
- 31, 31, 31, nil, 31, 32, 32, 32, 32, 32,
125
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
126
- 32, nil, 32, 33, 33, 33, 33, 33, 33, 33,
127
- 33, 33, 33, 33, 33, 33, 33, 33, 33, nil,
128
- 33, 34, 34, 34, 34, 34, 34, 34, 34, 34,
129
- 34, 34, 34, 34, 34, 34, 34, nil, 34, 35,
130
- 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
131
- 35, 35, 35, 35, 35, nil, 35, 36, 36, 36,
171
+ 31, 31, 31, 31, 31, 31, nil, 31, 36, 36,
132
172
  36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
133
- 36, 36, 36, nil, 36, 37, 37, 37, 37, 37,
173
+ 36, 36, 36, 36, 36, 36, 36, 36, 36, nil,
174
+ 36, 37, 37, 37, 37, 37, 37, 37, 37, 37,
134
175
  37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
135
- 37, nil, 37, 38, 38, 38, 38, 38, 38, 38,
136
- 38, 38, 38, 38, 38, 38, 38, 38, 38, nil,
137
- 38, 39, 39, 39, 39, 39, 39, 39, 39, 39,
138
- 39, 39, 39, 39, 39, 39, 39, nil, 39, 40,
176
+ 37, 37, nil, 37, 38, 38, 38, 38, 38, 38,
177
+ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
178
+ 38, 38, 38, 38, 38, nil, 38, 39, 39, 39,
179
+ 39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
180
+ 39, 39, 39, 39, 39, 39, 39, 39, nil, 39,
139
181
  40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
140
- 40, 40, 40, 40, 40, nil, 40, 4, 4, 4,
182
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
183
+ 40, nil, 40, 41, 41, 41, 41, 41, 41, 41,
184
+ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
185
+ 41, 41, 41, 41, nil, 41, 42, 42, 42, 42,
186
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
187
+ 42, 42, 42, 42, 42, 42, 42, nil, 42, 43,
188
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
189
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
190
+ nil, 43, 44, 44, 44, 44, 44, 44, 44, 44,
191
+ 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
192
+ 44, 44, 44, nil, 44, 45, 45, 45, 45, 45,
193
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
194
+ 45, 45, 45, 45, 45, 45, nil, 45, 46, 46,
195
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
196
+ 46, 46, 46, 46, 46, 46, 46, 46, 46, nil,
197
+ 46, 47, 47, 47, 47, 47, 47, 47, 47, 47,
198
+ 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
199
+ 47, 47, nil, 47, 48, 48, 48, 48, 48, 48,
200
+ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
201
+ 48, 48, 48, 48, 48, nil, 48, 49, 49, 49,
202
+ 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
203
+ 49, 49, 49, 49, 49, 49, 49, 49, nil, 49,
204
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
205
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
206
+ 50, nil, 50, 88, 88, 88, 88, 88, 88, 88,
207
+ 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
208
+ 88, 88, 88, 88, nil, 88, 4, 4, 4, 4,
141
209
  4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
142
- 4, 4, nil, 4, 29, 29, 29, 29, 29, 29,
143
- 29, 29, 29, 29, 29, 29, 29, 29, 29, nil,
144
- 29, 2, 2, 2, 2, 46, 46, 46, 46 ]
210
+ 4, 4, 4, 4, 4, 4, nil, 4, 34, 34,
211
+ 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
212
+ 34, 34, 34, 34, 34, 34, 34, 34, nil, 34,
213
+ 56, 56, 56, 56 ]
145
214
 
146
215
  racc_action_pointer = [
147
- 74, 20, 417, 1, 379, 26, 92, nil, nil, nil,
148
- 6, 7, 8, 10, 11, 12, 34, 36, 37, 38,
149
- nil, 64, 110, 128, 146, 164, 182, 63, nil, 396,
150
- -4, 200, 218, 236, 254, 272, 290, 308, 326, 344,
151
- 362, nil, 18, 22, nil, nil, 421, 64, nil, 0,
152
- 4, 8, 12, 34, 38, 42, 46, 50, 72, nil,
153
- nil, nil, nil, nil, nil, nil, nil, nil, nil ]
216
+ 130, 26, 110, 3, 658, 30, 153, nil, nil, nil,
217
+ 4, 6, 7, 8, 10, 11, 12, 14, 15, 16,
218
+ 42, 43, 45, 46, 47, nil, 78, 176, 199, 222,
219
+ 245, 268, 77, nil, 680, 0, 291, 314, 337, 360,
220
+ 383, 406, 429, 452, 475, 498, 521, 544, 567, 590,
221
+ 613, nil, 20, 24, nil, nil, 706, 78, nil, 4,
222
+ 8, 12, 16, 43, 47, 51, 55, 59, 63, 90,
223
+ 94, 98, 102, -4, nil, nil, nil, nil, nil, nil,
224
+ nil, nil, nil, nil, nil, nil, nil, nil, 636, 106,
225
+ nil ]
154
226
 
155
227
  racc_action_default = [
156
- -26, -26, -1, -11, -26, -8, -26, -12, -13, -14,
157
- -26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
158
- -25, -26, -26, -26, -26, -26, -26, -7, -11, -26,
159
- -26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
160
- -26, 69, -3, -4, -5, -6, -2, -9, -10, -26,
161
- -26, -26, -26, -26, -26, -26, -26, -26, -26, -15,
162
- -16, -17, -18, -19, -20, -21, -22, -23, -24 ]
228
+ -31, -31, -1, -11, -31, -8, -31, -12, -13, -14,
229
+ -31, -31, -31, -31, -31, -31, -31, -31, -31, -31,
230
+ -31, -31, -31, -31, -31, -30, -31, -31, -31, -31,
231
+ -31, -31, -7, -11, -31, -31, -31, -31, -31, -31,
232
+ -31, -31, -31, -31, -31, -31, -31, -31, -31, -31,
233
+ -31, 91, -3, -4, -5, -6, -2, -9, -10, -31,
234
+ -31, -31, -31, -31, -31, -31, -31, -31, -31, -31,
235
+ -31, -31, -31, -31, -15, -16, -17, -18, -19, -20,
236
+ -21, -22, -23, -24, -25, -26, -27, -28, -31, -31,
237
+ -29 ]
163
238
 
164
239
  racc_goto_table = [
165
- 2, 1, 27, nil, nil, nil, 30, nil, nil, nil,
240
+ 2, 1, 32, nil, nil, nil, 35, nil, nil, nil,
241
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
242
+ nil, nil, nil, nil, nil, nil, nil, 52, 53, 54,
243
+ 55, 56, 57, nil, nil, nil, 59, 60, 61, 62,
244
+ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
245
+ 73, nil, nil, nil, nil, nil, nil, nil, nil, nil,
166
246
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
167
- nil, nil, 42, 43, 44, 45, 46, 47, nil, nil,
168
- nil, 49, 50, 51, 52, 53, 54, 55, 56, 57,
169
- 58 ]
247
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
248
+ nil, nil, nil, nil, nil, nil, nil, nil, 89 ]
170
249
 
171
250
  racc_goto_check = [
172
251
  2, 1, 3, nil, nil, nil, 2, nil, nil, nil,
173
252
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
174
- nil, nil, 2, 2, 2, 2, 2, 3, nil, nil,
175
- nil, 2, 2, 2, 2, 2, 2, 2, 2, 2,
176
- 2 ]
253
+ nil, nil, nil, nil, nil, nil, nil, 2, 2, 2,
254
+ 2, 2, 3, nil, nil, nil, 2, 2, 2, 2,
255
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
256
+ 2, nil, nil, nil, nil, nil, nil, nil, nil, nil,
257
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
258
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
259
+ nil, nil, nil, nil, nil, nil, nil, nil, 2 ]
177
260
 
178
261
  racc_goto_pointer = [
179
262
  nil, 1, 0, -2 ]
@@ -183,35 +266,40 @@ racc_goto_default = [
183
266
 
184
267
  racc_reduce_table = [
185
268
  0, 0, :racc_error,
186
- 1, 27, :_reduce_1,
187
- 3, 27, :_reduce_2,
188
- 3, 28, :_reduce_3,
189
- 3, 28, :_reduce_4,
190
- 3, 28, :_reduce_5,
191
- 3, 28, :_reduce_6,
192
- 2, 28, :_reduce_7,
193
- 1, 28, :_reduce_none,
194
- 3, 29, :_reduce_9,
195
- 3, 29, :_reduce_10,
196
- 1, 29, :_reduce_11,
197
- 1, 29, :_reduce_none,
198
- 1, 29, :_reduce_13,
199
- 1, 29, :_reduce_14,
200
- 4, 29, :_reduce_15,
201
- 4, 29, :_reduce_16,
202
- 4, 29, :_reduce_17,
203
- 4, 29, :_reduce_18,
204
- 4, 29, :_reduce_19,
205
- 4, 29, :_reduce_20,
206
- 4, 29, :_reduce_21,
207
- 4, 29, :_reduce_22,
208
- 4, 29, :_reduce_23,
209
- 4, 29, :_reduce_24,
210
- 1, 29, :_reduce_25 ]
211
-
212
- racc_reduce_n = 26
213
-
214
- racc_shift_n = 69
269
+ 1, 33, :_reduce_1,
270
+ 3, 33, :_reduce_2,
271
+ 3, 34, :_reduce_3,
272
+ 3, 34, :_reduce_4,
273
+ 3, 34, :_reduce_5,
274
+ 3, 34, :_reduce_6,
275
+ 2, 34, :_reduce_7,
276
+ 1, 34, :_reduce_none,
277
+ 3, 35, :_reduce_9,
278
+ 3, 35, :_reduce_10,
279
+ 1, 35, :_reduce_11,
280
+ 1, 35, :_reduce_none,
281
+ 1, 35, :_reduce_13,
282
+ 1, 35, :_reduce_14,
283
+ 4, 35, :_reduce_15,
284
+ 4, 35, :_reduce_16,
285
+ 4, 35, :_reduce_17,
286
+ 4, 35, :_reduce_18,
287
+ 4, 35, :_reduce_19,
288
+ 4, 35, :_reduce_20,
289
+ 4, 35, :_reduce_21,
290
+ 4, 35, :_reduce_22,
291
+ 4, 35, :_reduce_23,
292
+ 4, 35, :_reduce_24,
293
+ 4, 35, :_reduce_25,
294
+ 4, 35, :_reduce_26,
295
+ 4, 35, :_reduce_27,
296
+ 4, 35, :_reduce_28,
297
+ 6, 35, :_reduce_29,
298
+ 1, 35, :_reduce_30 ]
299
+
300
+ racc_reduce_n = 31
301
+
302
+ racc_shift_n = 91
215
303
 
216
304
  racc_token_table = {
217
305
  false => 0,
@@ -234,14 +322,20 @@ racc_token_table = {
234
322
  :acos => 17,
235
323
  :atan => 18,
236
324
  :exp => 19,
237
- :log => 20,
238
- :log10 => 21,
239
- :v => 22,
240
- "=" => 23,
241
- "(" => 24,
242
- ")" => 25 }
243
-
244
- racc_nt_base = 26
325
+ :ln => 20,
326
+ :log => 21,
327
+ :abs => 22,
328
+ :fact => 23,
329
+ :floor => 24,
330
+ :ceil => 25,
331
+ :round => 26,
332
+ :v => 27,
333
+ "=" => 28,
334
+ "(" => 29,
335
+ ")" => 30,
336
+ "," => 31 }
337
+
338
+ racc_nt_base = 32
245
339
 
246
340
  racc_use_result_var = false
247
341
 
@@ -282,12 +376,18 @@ Racc_token_to_s_table = [
282
376
  "acos",
283
377
  "atan",
284
378
  "exp",
379
+ "ln",
285
380
  "log",
286
- "log10",
381
+ "abs",
382
+ "fact",
383
+ "floor",
384
+ "ceil",
385
+ "round",
287
386
  "v",
288
387
  "\"=\"",
289
388
  "\"(\"",
290
389
  "\")\"",
390
+ "\",\"",
291
391
  "$start",
292
392
  "statement",
293
393
  "expression",
@@ -307,7 +407,7 @@ module_eval(<<'.,.,', 'calc.y', 11)
307
407
 
308
408
  module_eval(<<'.,.,', 'calc.y', 12)
309
409
  def _reduce_2(val, _values)
310
- @v = @table[val[0]] = val[2]
410
+ @v = @table[val[0].to_sym] = val[2]
311
411
  end
312
412
  .,.,
313
413
 
@@ -357,7 +457,7 @@ module_eval(<<'.,.,', 'calc.y', 20)
357
457
 
358
458
  module_eval(<<'.,.,', 'calc.y', 21)
359
459
  def _reduce_11(val, _values)
360
- if @table[val[0]] then @table[val[0]] else raise("#{val[0]} not found.") end
460
+ if @table[val[0].to_sym] then @table[val[0].to_sym] else raise("#{val[0]} not found.") end
361
461
  end
362
462
  .,.,
363
463
 
@@ -377,66 +477,96 @@ module_eval(<<'.,.,', 'calc.y', 24)
377
477
 
378
478
  module_eval(<<'.,.,', 'calc.y', 25)
379
479
  def _reduce_15(val, _values)
380
- sqrt(val[2] )
480
+ sqrt(val[2])
381
481
  end
382
482
  .,.,
383
483
 
384
484
  module_eval(<<'.,.,', 'calc.y', 26)
385
485
  def _reduce_16(val, _values)
386
- sin(val[2] )
486
+ sin(val[2])
387
487
  end
388
488
  .,.,
389
489
 
390
490
  module_eval(<<'.,.,', 'calc.y', 27)
391
491
  def _reduce_17(val, _values)
392
- cos(val[2] )
492
+ cos(val[2])
393
493
  end
394
494
  .,.,
395
495
 
396
496
  module_eval(<<'.,.,', 'calc.y', 28)
397
497
  def _reduce_18(val, _values)
398
- tan(val[2] )
498
+ tan(val[2])
399
499
  end
400
500
  .,.,
401
501
 
402
502
  module_eval(<<'.,.,', 'calc.y', 29)
403
503
  def _reduce_19(val, _values)
404
- asin(val[2] )
504
+ asin(val[2])
405
505
  end
406
506
  .,.,
407
507
 
408
508
  module_eval(<<'.,.,', 'calc.y', 30)
409
509
  def _reduce_20(val, _values)
410
- acos(val[2] )
510
+ acos(val[2])
411
511
  end
412
512
  .,.,
413
513
 
414
514
  module_eval(<<'.,.,', 'calc.y', 31)
415
515
  def _reduce_21(val, _values)
416
- atan(val[2] )
516
+ atan(val[2])
417
517
  end
418
518
  .,.,
419
519
 
420
520
  module_eval(<<'.,.,', 'calc.y', 32)
421
521
  def _reduce_22(val, _values)
422
- exp(val[2] )
522
+ exp(val[2])
423
523
  end
424
524
  .,.,
425
525
 
426
526
  module_eval(<<'.,.,', 'calc.y', 33)
427
527
  def _reduce_23(val, _values)
428
- log(val[2] )
528
+ log(val[2])
429
529
  end
430
530
  .,.,
431
531
 
432
532
  module_eval(<<'.,.,', 'calc.y', 34)
433
533
  def _reduce_24(val, _values)
434
- log10(val[2] )
534
+ log10(val[2])
435
535
  end
436
536
  .,.,
437
537
 
438
538
  module_eval(<<'.,.,', 'calc.y', 35)
439
539
  def _reduce_25(val, _values)
540
+ val[2].abs
541
+ end
542
+ .,.,
543
+
544
+ module_eval(<<'.,.,', 'calc.y', 36)
545
+ def _reduce_26(val, _values)
546
+ fact(val[2])
547
+ end
548
+ .,.,
549
+
550
+ module_eval(<<'.,.,', 'calc.y', 37)
551
+ def _reduce_27(val, _values)
552
+ val[2].floor.to_f
553
+ end
554
+ .,.,
555
+
556
+ module_eval(<<'.,.,', 'calc.y', 38)
557
+ def _reduce_28(val, _values)
558
+ val[2].ceil.to_f
559
+ end
560
+ .,.,
561
+
562
+ module_eval(<<'.,.,', 'calc.y', 39)
563
+ def _reduce_29(val, _values)
564
+ val[2].round(val[4]).to_f
565
+ end
566
+ .,.,
567
+
568
+ module_eval(<<'.,.,', 'calc.y', 40)
569
+ def _reduce_30(val, _values)
440
570
  @v
441
571
  end
442
572
  .,.,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s_calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshio Sekiya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: CUI Scientific calculator
14
14
  email: lxboyjp@gmail.com
@@ -17,13 +17,15 @@ executables:
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - README.md
20
21
  - bin/calc
21
22
  - lib/calc.rb
22
23
  - lib/calc/calc.rb
23
24
  homepage: https://github.com/ToshioCP/calc
24
25
  licenses:
25
26
  - GPL-3.0
26
- metadata: {}
27
+ metadata:
28
+ documentation_uri: https://toshiocp.github.io/calc/
27
29
  post_install_message:
28
30
  rdoc_options: []
29
31
  require_paths: