0
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.

インタープリタを作る その32

Last updated at Posted at 2022-01-11

#概要

インタープリタを作ってみた。
jsforthを使ってみた。
sandbox作ってみた。

#フィボナッチ数列

: fib 7 0 1 rot 0 do swap over + dup . loop ;  ok
fib


1 2 3 5 8 13 21

#九九

: kuku 10 1 do 10 1 do i j * . loop cr loop ;
kuku
    

1 2 3 4 5 6 7 8 9 
2 4 6 8 10 12 14 16 18 
3 6 9 12 15 18 21 24 27 
4 8 12 16 20 24 28 32 36 
5 10 15 20 25 30 35 40 45 
6 12 18 24 30 36 42 48 54 
7 14 21 28 35 42 49 56 63 
8 16 24 32 40 48 56 64 72 
9 18 27 36 45 54 63 72 81 

#fizzbuzz

: sp 32 emit ;
: fizzbuzz 100 1 do i 3 mod 0 = i 5 mod 0 = or if i 3 mod 0 = if ." fizz" then i 5 mod 0 = if ." buzz" then else i . then sp loop ;
fizzbuzz

1  2  fizz 4  buzz fizz 7  8  fizz buzz 11  fizz 13  14  fizzbuzz 16  17  fizz 19  buzz fizz 22  23  fizz buzz 26  fizz 28  29  fizzbuzz 31  32  fizz 34  buzz fizz 37  38  fizz buzz 41  fizz 43  44  fizzbuzz 46  47  fizz 49  buzz fizz 52  53  fizz buzz 56  fizz 58  59  fizzbuzz 61  62  fizz 64  buzz fizz 67  68  fizz buzz 71  fizz 73  74  fizzbuzz 76  77  fizz 79  buzz fizz 82  83  fizz buzz 86  fizz 88  89  fizzbuzz 91  92  fizz 94  buzz fizz 97  98  fizz 

#zundoko

: zundoko 0 begin 2 random if ." zun " 1 + else ." doko " drop 0 then dup 4 = until ." doko kiyoshi!" ;  ok
zundoko
    

zun zun doko zun zun doko doko zun zun zun doko zun doko zun zun zun zun doko kiyoshi!

#成果物

以上。

0
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
0
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?