[Haskell-cafe] Re: New slogan for haskell.org

apfelmus apfelmus at quantentunnel.de
Tue Nov 27 17:34:25 EST 2007

Henning Thielemann wrote:
> apfelmus wrote:
>> Back then, I was given the task to calculate some sequence
>> of numbers which I did in one page of C code. So far so good, but when I
>> asked the task assigner about his solution, he responded: "Ah, this
>> problem, that's 1 line in Haskell. Well, 2 lines if the terminal is too
>> small."
> Ah, a Haskell code contribution to the Encyclopedia of Integer Sequences?

The task was just for fun, but it's sequence A050000.

   import Data.Set

   xs = let f x m = x:let y = x `div` 2 in f (if member y m then 3*x 
else y) (insert x m) in f 1 (singleton 0)

As said, it's two lines if the terminal is too small :)


More information about the Haskell-Cafe mailing list