haskellf#functional-programmingjtacit-programming

Have J style adverbs, forks etc been emulated via libraries in mainstream functional languages?


Has an emulation of J style of super condensed tacit programming via verbs, adverbs, forks, etc., ever been attempted via libraries for mainstream functional languages?

If so, how successful was the result?

If not, is there a technical issue that makes this impossible, or is it just not worth doing?

I'm particularly interested in constructs like forks that don't appear to correspond directly to basic concepts in functional programming.


Solution

  • Camccann's discussion is pretty good. But note that this style now results in two traversals.

    You can write a combinator library that merges the traversals. See here: http://squing.blogspot.com/2008/11/beautiful-folding.html

    The post offers the following example for writing a mean:

    meanF :: Fractional a => Fold a a
    meanF = bothWith (/) sumF (after lengthF fromIntegral)
    
    mean :: Fractional a => [a] -> a
    mean = cfoldl' meanF
    

    Also, Conal Eliott's followup posts generalize this much further: http://conal.net/blog/posts/enhancing-a-zip/

    He pulled the code from his posts into a library available on hackage: http://hackage.haskell.org/package/ZipFold