The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Y-combinator in Ruby with REAL λ!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Florian Frank

Posts: 48
Nickname: ffrank
Registered: Dec, 2005

Florian Frank is a humanoid life-form, living on the third planet of the solar system.
Y-combinator in Ruby with REAL λ! Posted: Oct 8, 2007 10:23 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Florian Frank.
Original Post: Y-combinator in Ruby with REAL λ!
Feed Title: The Rubylution: Tag Ruby
Feed URL: http://rubylution.ping.de/xml/rss/tag/ruby/feed.xml
Feed Description: Starts… Now.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Florian Frank
Latest Posts From The Rubylution: Tag Ruby

Advertisement
#!/usr/bin/ruby -KU
# -*- coding: utf-8 -*- 

# Do ":map! <C-l> <C-k>l*" in vim

alias λ lambda

Y = λ{ |c|
  λ{ |f| f[f] }[
    λ{ |f| c[
      λ{ |x| f[f][x] } ] } ] }

Y[ λ{ |f| λ{ |n| n < 1 ? 1 : n * f[n-1] } } ][10] # => 3628800

And they say reading ruby-core doesn't pay off! :-)

Read: Y-combinator in Ruby with REAL &lambda;!

Topic: Are you nuts or stupid? Nevermind, I know the answer to that. Previous Topic   Next Topic Topic: Multiple Database Connections in Ruby on Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use