2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

概要

paiza.ioでelixirやってみた。
Forth、見つけたのでやってみた。

参考にしたページ

サンプルコード

Forth.is_integer_str("123")
Forth.is_integer_str("+123")
Forth.is_integer_str("-123")
Forth.is_integer_str("890")
Forth.is_integer_str("+890")
Forth.is_integer_str("-890")
Forth.is_float_str("123.1")
Forth.is_float_str("120.1")
Forth.is_float_str("123.1e10")
Forth.is_float_str("120.1e22") 
Forth.foo("1 1 + .\n")
#Forth.foo(" 1	1	+	 .\n") 
Forth.foo("3 1+ .\n") 
Forth.foo("10 1- .\n") 
Forth.foo("4 2* .\n") 
Forth.foo("11 2/ .\n") 
Forth.foo("1.1 1.1 + .\n")
Forth.foo("17 23 - .\n") 
Forth.foo("5 7 * .\n") 
Forth.foo("365 7 / .\n") 
Forth.foo("1000 2 3 */ .\n") 
Forth.foo("255 43 mod .\n") 
Forth.foo("255 43 /mod . .\n") 
Forth.foo("-3 abs .\n") 
Forth.foo("2 3 max .\n")
Forth.foo("2 3 min .\n")
Forth.foo("2 negate .\n")
Forth.foo("-2 negate .\n")
Forth.foo("2 dup . .\n") 
Forth.foo("2 3 drop .\n")
Forth.foo("2 3 swap . .\n")
Forth.foo("-2 67 4 rot . . .\n") 
Forth.foo("4 8 9 over . . .\n") 
Forth.foo(".\" Hello\"\n") 
Forth.foo("1 2 .s\n") 
Forth.foo("2 5 73 -16 + - * .\n")	
Forth.foo("0 if 1 else 2 endif .\n")
Forth.foo("-1 if 1 else 2 endif .\n")
Forth.foo("1 2 = .\n")
Forth.foo("2 2 = .\n")
Forth.foo("1 2 < .\n")
Forth.foo("1 2 < .\n")
Forth.foo("1 2 > .\n")
Forth.foo("1 2 < .\n")
Forth.foo("2 1 > .\n")
Forth.foo("2 1 < .\n")
Forth.foo("10 0 ?do i . loop\n") 
Forth.foo("3 0 do i . 4 0 do j . loop loop\n") 
Forth.foo("50 0 do i . 5 +loop\n") 
Forth.foo("-10 0 do i . -1 +loop\n") 
Forth.foo(": fib 0 1 rot 0 ?do over + swap loop drop ; 10 fib .\n")

実行結果

2 ok
4 ok
9 ok
8 ok
5 ok
2.2 ok
-6 ok
35 ok
52 ok
666 ok
40 ok
5 40 ok
3 ok
3 ok
2 ok
-2 ok
2 ok
2 2 ok
2 ok
2 3 ok
-2 4 67 ok
8 9 8 ok
Hello ok
<2> 1 2 ok
-104 ok
2 ok
1 ok
0 ok
-1 ok
-1 ok
-1 ok
0 ok
-1 ok
-1 ok
0 ok
0 1 2 3 4 5 6 7 8 9 ok
0 0 1 2 3 1 0 1 2 3 2 0 1 2 3 ok
0 5 10 15 20 25 30 35 40 45 ok
0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 ok
55 ok

成果物

https://paiza.io/projects/s4S8JHQ71NFOp0BAeJ8vvg
以上。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?