Exercise1-1 <---> Exercise1-3
Exercise 1.2.
Translate the following expression into prefix form
Ru: Переведите следующее выражение в префиксную форму
Scheme solution:
(/ (+ 5 4 (- 2 (- 3 (+ 6 4/5))))
(* 3 (- 6 2) (- 2 7)))
Haskell solution:
((/) ((+) 5 ((+) 4 ((-) 2 ((-) 3 ((+) 6 ((/) 4 5))))))
((*) 3 ((*) ((-) 6 2) ((-) 2 7))))
Exercise1-1 <---> Exercise1-3
Comments
| Haskell solution rulez! | ||||
| Posted by IvanVeselov at 2007-09-14 22:48:29 | ||||
I suppose LISP solution would have less brackets than Haskell! | ||||
| Posted by 80 at 2007-09-18 00:39:21 X | ||||
Please, hide solutions under link | ||||
| Posted by 88-134-214-69-dynip at 2007-09-18 07:37:54 X | ||||
Haskell is a complicated and sugared Lisp! :o) Compare this: (define fib
(lambda (n)
(if (< n 3)
1
(+ (fib (- n 1))
(fib (- n 2))))))
with Haskell: fib =
(\n ->
(iff ((<) n 3)
1
((+) (fib ((-) n 1))
(fib ((-) n 2)))))
iff =
(\p t e ->
if p then t else e)
| ||||
| Posted by Geniepro at 2007-09-18 15:41:13 | ||||
> Please, hide solutions under link OK, I will look what can be done. | ||||
| Posted by IvanVeselov at 2007-09-18 19:34:04 | ||||
(/ (+ 5
| ||||
| Posted by Eric at 2007-10-09 08:54:44 X | ||||