Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Going through SICP in Haskell

Name: Anonymous 2010-03-26 11:27

I've been going through SICP, first in Scheme and then in Haskell, and I started wondering...

Is my Haskell too Lisp-y?

filterAccumulate
    :: (Eq t1) =>
       (t1 -> Bool) -> (t2 -> t3 -> t3) -> t3 -> (t1 -> t2) -> t1 -> (t1 -> t1) -> t1 -> t3
filterAccumulate filter combiner nullVal term a next b =
    iter a nullVal
    where
    iter a result =
        if (a == b) then filterCombiner a result
        else iter (next a) (filterCombiner a result)
    filterCombiner a result =
        if (filter a) then combiner (term a) result
        else result

Name: Anonymous 2010-03-26 15:14

>>8
I should say probably say what those SRFIs are.
SRFI 8 is receive, which is just a macro around call-with-values. IIRC R6RS standardised let-values, but that looks ugly when you want to get the values of one expression, which, for me anyway, is the common case.
SRFI 26 provides cut and cute which are just macros for specialising functions. It works out much nicer than having to explicitly write the lambdas or currying you scheme code.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List