5 ms·
module Main { IO<Void> main() { Integer n <- read$(getLine) // or: fmap(read)(getLine) print(fib(n)) } Integer fib(Integer n) {
by ferzul 7y ago
module Main {
IO<Void> main() {
Integer n <- read$(getLine) // or: fmap(read)(getLine)
print(fib(n))
}
Integer fib(Integer n) {
Integer go(Integer !n, Integer !a, Integer !b) {
if (n==0) {
return 0
} else {
return go(n-1, b, a+b)
}
}
}
}
pros: it looks plausibly like Java.
cons: all the things that haskell syntax makes easy like partial application become obscure at best. omg, i'm dying in squiggly and round brackets, what is this, lisp? there's too much stuff that has to become ad hoc builtin syntax, like <$> becomes $(...). i don't know if you can program applicatively with this syntax, but i doubt you could have invented it.