- 1 tomato, chopped into rough chunks
- Some lettuce, chopped into rough pieces
- 2 tortillas
- Half a can of refried beans
- Half a tub of salsa
- A bit of grated cheese
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trial where | |
import System.IO | |
import System.Directory | |
import System.Time | |
fileExists :: FilePath -> IO Bool | |
fileExists name = do | |
fileExists <- doesFileExist name | |
if fileExists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
right :: Either a b -> Maybe b | |
right = either (\a -> Nothing) (\b -> Just b) | |
-- With more win: | |
right :: Either a b -> Maybe b | |
right = either (\a -> mzero) return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Enumerable | |
def name_please &blk | |
inject({}) do |accum, elem| | |
accum[elem] = blk.call(elem) | |
accum | |
end | |
end | |
end | |
[1,2].name_please { |x| "#{x} value" } # <= { 1 => "1 value", 2 => "2 value" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://github.com/evanphx/rubinius/tree/master/lib/actor.rb | |
# Stripped ends as a `rong` prototype | |
class Actor | |
class DeadActorError < RuntimeError | |
attr_reader :actor | |
attr_reader :reason | |
def initialize(actor, reason) | |
super(reason) | |
@actor = actor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def box | |
self.is_a?(Array) ? self : [self] | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Making RubyMine Pro-er | |
----------------------- | |
File->Settings | |
Editor | |
[ ] Allow placement of caret after end of line | |
Editor -> Editor Tabs | |
[x] Show tabs in single row | |
Editor -> Appearance | |
[x] Use antialiased font |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo gem uninstall nkpart-accidently | |
sudo gem install nkpart-accidentally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = %w{1.3 1.5 1.8} | |
puts "# 1 - standard stuff" | |
p numbers.map { |x| x.to_f } | |
puts "# 2 - passing in a proc using &" | |
to_f_proc = proc { |x| x.to_f } | |
p numbers.map(&to_f_proc) | |
puts "# 3 - passing in a dynamic proc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prohax' | |
def add a | |
let( :to => proc { |b| b + a }) | |
end | |
add(5).to(3) | |
# => 8 | |
def _if s |