Skip to content

stmtk1/first_prog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usage

四則演算

> 1 + 1 -> 2
> 1 - 1 -> 0
> 2 * 4 -> 8
> 4 / 3 -> 1.25

## 更に累乗・割り算のあまりももとめられる

> 10 % 3 -> 1
> 2 ^ 3 -> 8

演算子の優先順位

普通の数式でも足し算・引き算より掛け算・割り算のほうが先に処理されるので、そのような実装にしました。 また掛け算割り算より累乗・割り算の方が先に処理されます

> (1 + 2) * 4 -> 12
> 1 + 2 * 4 -> 9
> 10 * 7 % 4 -> 30
> (10 * 7) % 4 -> 2

変数の代入

普通のプログラミング言語と同じように変数に代入ができますが、a = b = 1のような処理をしようとするとパースエラーになります。

> a = 1 + 2 * 3
> a + 10 -> 17

関数の定義

自分で関数を定義してそれを使うこともできます。2つ以上の引数を取る関数は定義できません。

> defun double(a) a * a
> double(a)

About

初めて作ったプログラミング言語です

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages