class Symbol
def -@
to_s.reverse.to_sym
end
end
class Fixnum
def to_proc
lambda { self }
end
end
class Regexp
def -@
to_s
end
def to_proc
lambda { self }
end
end
class Array
def -@
reverse
end
def to_proc
lambda {|i| self[i] }
end
end
p -:hello
p [nil].map(&10)
p -/quick/
p [nil].map(&/cool/)
p -[1, 2, 3]
p [0, 1, 1, 2].map(&[:a, :b, :c])
Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa
Friday, June 5, 2009
The Possibility of Unary Operators
Subscribe to:
Post Comments (Atom)
About Me
Blog Archive
-
▼
2009
(103)
-
▼
June
(18)
- VimM#4
- The First Visit to Japan in the Past 3 Months
- Question About Making Slides
- Markdown with LaTeX with Beamer
- Pandoc the Ultimate Markdown Utility
- Haddock Install Failed
- One of The Worst Trap with MacBook Air
- A Problem with Skype in a Specific Room
- It Is Difficult To Extend Ruby's Syntax of Definin...
- My Birthday
- Default Parameter -- Dynamic Define, Recursive Call
- RubyGems Best Practice
- Defining Instance Method Easily and Viscerally
- Inescapable Bafflegab in Vim
- The Possibility of Unary Operators
- Installing Ruby 1.9.1 By Source Code
- (Draft) Extended Markdown for Vim Hacks
- Dvorak keymapping for Vim users
-
▼
June
(18)
No comments:
Post a Comment