Sep. 17th, 2011

melanoman: (Default)
I'm looking at the examples on this page and so far everything looks like scheme with the verbs moved around.

The option bind example tweaked me as being really bad code. The expression

new F<Integer, Option<Integer>>() {  
    public Option<Integer> f(final Integer i) {  
        if(i % 2 == 0) return some(i * 3); else return none();  
    }
}


is repeated thrice. Why not save the expression in a variable?

F<Integer, Option<Integer>>() trippleOdd = new F<Integer, Option<Integer>>() 
{  
    public Option<Integer> f(final Integer i) 
    {  
        if(i % 2 == 0) return some(i * 3); 
        else return none();  
    }
};


As far as I can tell the scope bindings would all be identical and the result is unchanged. Switching from learning mode to judgmental mode: This is Bad Code(tm) unless someone can tell me why it isn't.
melanoman: (Default)
Name reminds me of Leave It to Beaver

not-equals is /= instead of !=

LHFGG says ++ implementation has O(|left|) concatenation instead of O(1).
Look for a streams implementation. (see "comprehension" below)
colon is the cons operator
list.get(x) is !! x

car/cdr is head/tail
last/butlast is last/init

cddddr is drop 4 (where 4 is the count of d's) so tail is drop 1

max and min are spelled out
[x..y] specifies a range with step +1
[x,x2..y] specifies a range with step (x2-x1)
.. works for floats

map-filter combo is call a "comprehension"
[expression | x<-[range], constraint]
func x y can be syntactic sugared as x `func` y

let makes variables (scope?)

The following works, so cons-stream is lazy as it should be
let nats = [1,2..]
let evens = [2*x | x<-nats]
let bomb = nats ++ evens
take 4 bomb


Multiple ranges does a walk of all combinations with first list incrementing most slowly and so on.

underscore is used both as a void type and /dev/null for values

If an = without a let a function declaration?
let expr = value
myFunc arg = value

Profile

melanoman: (Default)
melanoman

March 2013

S M T W T F S
     12
3456789
10111213141516
17181920212223
2425262728 2930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 21st, 2017 06:53 am
Powered by Dreamwidth Studios