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

Ruby is beautiful

Name: Anonymous 2009-08-26 15:25

class Cycle
    def cycle(*args)
      args[((@_cycles ||= Hash.new(-1))[args.hash] += 1) % args.size]
    end
end

More beautiful code plees?

Name: Anonymous 2009-08-27 16:53

import Data.Map
import Data.IORef

newCycle =
   do state <- newIORef empty
      let memoCycle args =
             do modifyIORef state $ alter (Just . maybe (cycle args) tail) args
                fmap (head . (!args)) $ readIORef state
      return memoCycle

main =
   do foo <- newCycle
      putStrLn =<< foo ["hax","my","anus"]
      putStrLn =<< foo ["hax","my","anus"]
      putStrLn =<< foo ["achieve","satori"]
      putStrLn =<< foo ["hax","my","anus"]
      putStrLn =<< foo ["hax","my","anus"]

Name: Anonymous 2009-08-27 17:00

>>31
I just thought about writing something using IORefs just to show >>24-26 that it's possible. Good thing you were faster though, as I've never used IORefs before.

Name: Anonymous 2009-08-27 18:00

modifyIORef state $ alter (Just . maybe (cycle args) tail) args
fmap (head . (!args)) $ readIORef state
god, why

Name: Anonymous 2009-08-27 18:04

>>33
Because you're stupid.

Name: Anonymous 2009-08-27 18:05

>>34
What about my am stupid?

Name: Anonymous 2009-08-27 18:58

>>31
Couldn't you at least have given nice names like pop and peek to those gruesome HOFs?

Name: Anonymous 2009-08-27 19:04

>>31
Oh please. U MENA let {f' = foo ["hax", "my", "anus"]; f'' = ["achieve", "satori"]}; mapM_ (putStrLn =<<) [f',f',f'',f',f']

Name: Anonymous 2009-08-27 19:14

>>37
main = do
  foo <- newCycle
  let fooSharp = (putStrLn =<<) . foo . words
      [x,y] = fooSharp `map` ["hax my anus", "achieve satori"]
  sequence_ [x, x, y, x, x]

Name: Anonymous 2009-08-27 19:49

>>36
I don't know, couldn't you at least try not being a faggot?

>>37,38
main =
   do foo <- newCycle
      let (x, y) = ("hax my anus","achieve satori")
      mapM_ ((putStrLn =<<) . foo . words) [x, x, y, x, x]

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