On 3 Jan 2008, at 4:49 AM, Isaac Dupree wrote:
Achim Schneider wrote:
Achim Schneider <[EMAIL PROTECTED]> wrote:
[...]
I'm trying to grok that
[] = id
++ = .
in the context of Hughes lists.
they are also known as "difference lists", and also used at type
String in the Prelude as "ShowS", to help avoid quadratic behavior
when making complicated Strings. the [a]->[a] is not an ordinary
function -- it's expected not to examine its argument, just to use
it exactly once (is there a formal way to say that?)
f xn = f [] ++ xn
is the first thing off the top of my head.
OTOH, examining your argument (while, strictly speaking unsafe) is
pretty darn cool:
f [] = "foo"
f (c:s) | isAlphaNum c = "foo "++c:s
| otherwise = "foo"++c:s
Token prepend.
jcc
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe