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

Haskell

Name: Anonymous 2007-10-03 23:44

Hi /prog/, i'm doing a basic programming course at uni and the lecturer has set a challenge to write the id Haskell prelude function recursively:

id :: a -> a
id x = x

I can't think of a way to do this which is meaningful, any ideas (this isn't marked or anything so i'm not in any way cheating).

Name: Anonymous 2007-10-04 7:33

CAPTAIN ENTERPRISE to the rescue!

enterpriseMissionCriticalIdentityFunction :: a -> a
enterpriseMissionCriticalIdentityFunction x =
  enterpriseNTierIdentityFunction x null null null null null null null 69 -- Scalable!
  where
    enterpriseNTierIdentityFunction x _ _ _ _ _ _ _ n
      | n > 0 = enterpriseNTierIdentityFunction x null null null null null null null (n - 1)
      | otherwise = x

main = do
  print $ enterpriseMissionCriticalIdentityFunction 1

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