Hi everyone,

I'm finally back to learn Alice, and the problem of the day is how to make
this nicer:

 List.sort (fn (a,b)=>Int.compare ((look b), (look a))) aList

where look is a function that does some calculations on the arguments
(well, a Map lookup, actually).

Now, what I'd like to do is build the comparation function via function
composition instead of using the inline definition.

If compare was a single-valued function I'd do:
 Int.compare o look

but since it takes 2 args I don't know how to handle it.

My solution would be 
 fun productCompose f g= fn (a,b)=>g(f a,f b);
 val productCompose : ('a -> 'b) -> ('b * 'b -> 'c) -> 'a * 'a -> 'c = _fn


but it seem too specific, and I wonder if there is a general approach
(apart from function definition :) 

Is it possible to define (or better, it is alread there) an n-compose
function that I could use in conjunction with Fn.curry ? 

I am unable to find a type for it, but I have the feeling it is impossible
to define (I can't come up with a type for it) ?



-- 
goto 10: http://www.goto10.it
blog it: http://riffraff.blogsome.com
blog en: http://www.riffraff.info


_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to