Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Arithmetic-Integer/NewLISP/arithmetic-integer.l
Normal file
24
Task/Arithmetic-Integer/NewLISP/arithmetic-integer.l
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
; integer.lsp
|
||||
; oofoe 2012-01-17
|
||||
|
||||
(define (aski msg) (print msg) (int (read-line)))
|
||||
(setq x (aski "Please type in an integer and press [enter]: "))
|
||||
(setq y (aski "Please type in another integer : "))
|
||||
|
||||
; Note that +, -, *, / and % are all integer operations.
|
||||
(println)
|
||||
(println "Sum: " (+ x y))
|
||||
(println "Difference: " (- x y))
|
||||
(println "Product: " (* x y))
|
||||
(println "Integer quotient (rounds to 0): " (/ x y))
|
||||
(println "Remainder: " (setq r (% x y)))
|
||||
|
||||
(println "Remainder sign matches: "
|
||||
(cond ((= (sgn r) (sgn x) (sgn y)) "both")
|
||||
((= (sgn r) (sgn x)) "first")
|
||||
((= (sgn r) (sgn y)) "second")))
|
||||
|
||||
(println)
|
||||
(println "Exponentiation: " (pow x y))
|
||||
|
||||
(exit) ; NewLisp normally goes to listener after running script.
|
||||
Loading…
Add table
Add a link
Reference in a new issue