Re:The Power of The Functional or: I’ll bet you can’t do thi...
by seertaak on Wednesday December 10, 2008 @04:55AM
(#392712)
Except that this isn't really quicksort, because it's not in-place. Let's see you write the real one; I bet you it will be uglier than the equivalent java code.
Re:The Power of The Functional or: I’ll bet you can’t do thi...
by litewulf on Wednesday December 10, 2008 @02:40AM
(#392619)
Well, Java has Comparator classes. You can simply have first class functions by making a generic-d class (generic types for input and output), and a single member like "public T apply(F arg)". Its not that out of the ordinary.
So the paradigm is easily replicated, but yes, the syntax is totally ugly though ;) I think the real difficulty is in explaining how say lots of Comparators and Function classes are better or worse than a first-class function. Java at least affords type-safety on the wrapped functions whereas Ruby and Python don't (though, they don't really have any Java-style type safety to begin with).
Re:The Power of The Functional or: I’ll bet you can’t do thi...
by smanek on Wednesday December 10, 2008 @08:50AM
(#392878)
You're right - Haskell does lazy evaluation far better than Lisp/Scheme do. I've been making my way through real world haskell, and I'm constantly amazed.
I'm not proficient enough in Haskell to write a public blog post on it though; and I figure Lisp was esoteric enough ;-)
Re:The Power of The Functional or: I’ll bet you can’t do thi...
by jorgeortiz85 on Wednesday December 10, 2008 @02:19AM
(#392593)
Oh, they compile now. They're just ugly.
quicksort:
qsort [] = []
qsort (x:xs) = qsort (filter (<= x) xs) ++ [x] ++ qsort (filter (> x) xs)
fib sequence:
fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist))
but don't worry, with the rate at which the java kitchen sink swallows more paradigms, this will likely compile in java8 or something