[Haskell-cafe] What is this function?

John Ky newhoggy at gmail.com
Thu Oct 16 05:00:55 EDT 2008


I've written this function here:

   scramble [] = []
   scramble [x] = [[z] | z <- scramble x]
   scramble (x:xs) =
      [(y:z)|y <- scramble x, z <- scramble xs]

and (I think) it roughly does what I want it to:

   *Main> scramble ([]::[Int])
   *Main> scramble ([1]::[Int])
   *Main> scramble ([1,2]::[Int])
   *Main> scramble ([1,2,3]::[Int])

Three questions:

1. What should I call this function?
2. Is there already one in the standard library that does the same thing?
3. Is it possible to rewrite it with only "scramble []" and "scramble
(x:xs)" and not the "scramble[x]"?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081016/8621f1a6/attachment.htm

More information about the Haskell-Cafe mailing list