Lisp-arithmetic-operators
提供:Dev Guides
LISP-算術演算子
次の表は、LISPでサポートされているすべての算術演算子を示しています。 変数 A が10を保持し、変数 B が20を保持すると仮定します-
Operator | Description | Example |
---|---|---|
+ | Adds two operands | (+A B) will give 30 |
- | Subtracts second operand from the first | (- A B) will give -10 |
* | Multiplies both operands | (* A B) will give 200 |
/ | Divides numerator by de-numerator | (/B A) will give 2 |
mod,rem | Modulus Operator and remainder of after an integer division | (mod B A )will give 0 |
incf | Increments operator increases integer value by the second argument specified | (incf A 3) will give 13 |
decf | Decrements operator decreases integer value by the second argument specified | (decf A 4) will give 9 |
例
main.lispという名前の新しいソースコードファイルを作成し、次のコードを入力します。
実行ボタンをクリックするか、Ctrl + Eを入力すると、LISPはすぐに実行し、返される結果は-