Wednesday, September 21, 2011

Conundrum, a sample of UTF-8 in Ruby 1.9.2

Posted to Github as this gist.

# encoding: utf-8
# conundrum.rb
alias :λ :lambda
alias :Ω :abort

module Enumerable
alias :⇔ :collect
alias :∉ :reject
alias :∈ :select
alias :∫ :inject
alias :∀ :all?
alias :∃ :any?
end

class Array
alias :× :each
alias :⊠ :each_index
alias :≡ :eql?
alias :∋ :include?
alias :∪ :|
alias :∩ :&
end

%w(a b c).× do |letter| puts letter; end

%w(a b c).∪ %w(x y z) do |letter| puts letter; end

%w(a b c).∩ %w(c y z) do |letter| puts letter; end

a = λ {|s| puts s}
a.call('test')

Ω "It is the end"

Post a Comment