Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created August 28, 2013 04:30
Show Gist options
  • Select an option

  • Save supermomonga/6362149 to your computer and use it in GitHub Desktop.

Select an option

Save supermomonga/6362149 to your computer and use it in GitHub Desktop.
def cloop(*params, &block)
  r = ->(*xs){ block.(r, *xs) }
  r.(*params)
end

クイズ

上記cloopを用いてmap, select, injectを実装せよ

あ、ただしrecurの呼び出しがそのまま返り値となる、という節約つけたほうがいいかな

dame

def map(xs, &block)
  hoge
  if moge
    somefunc(recur.(that))
  end
end

iiyo

def map(xs, &block)
  hoge
  if moge
    recur.(that)
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment