This file contains hidden or 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
# This program prints out: | |
# | |
# Reversed: god | |
# God | |
# | |
# I originally found it in the documentation | |
# of BasicObject#tap in "Programming Ruby 1.9" by Dave Thomas | |
# | |
puts "dog" |
This file contains hidden or 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
def reverse(a) a.reverse; end |
This file contains hidden or 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
def sanitize(w,s)s.tr('/*-._\\','').sub(/#{w}/i,'*'*w.size)end |
This file contains hidden or 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
# ruby -v | |
# ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.8.0] | |
# | |
# note that you shouldn't use class variables anyhow... | |
class Foo | |
@@in_foo = 2 | |
def self.in_foo; @@in_foo; end | |
end |
This file contains hidden or 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
def foo(nums) | |
h = Hash.new([]) | |
nums.each { |n| h[n] << n } | |
puts h.inspect | |
puts h['foo'] | |
end | |
#YETANOTHERREASONMUTABLESTATEISTERRIBLE |
This file contains hidden or 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 Array | |
alias_method :>>, :delete | |
end | |
a = [] | |
a << 1 | |
a << 2 | |
a << 3 |
This file contains hidden or 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
Excepting deserializing game: System.ArgumentNullException: Argument cannot be null. | |
Parameter name: array | |
at Microsoft.FSharp.Collections.ArrayModule.Fold[EntityId,SetTree`1] (Microsoft.FSharp.Core.FSharpFunc`2 folder, Microsoft.FSharp.Collections.SetTree`1 state, CoinDB.EntityId[] array) [0x00000] in <filename unknown>:0 | |
at Microsoft.FSharp.Collections.SetTreeModule.ofArray[EntityId] (IComparer`1 comparer, CoinDB.EntityId[] l) [0x00000] in <filename unknown>:0 | |
at Microsoft.FSharp.Collections.FSharpSet`1[CoinDB.EntityId].OnDeserialized (StreamingContext context) [0x00000] in <filename unknown>:0 | |
at System.Runtime.Serialization.SerializationCallbacks.Invoke (System.Collections.ArrayList list, System.Object target, StreamingContext context) [0x00000] in <filename unknown>:0 | |
at System.Runtime.Serialization.SerializationCallbacks.RaiseOnDeserialized (System.Object target, StreamingContext contex) [0x00000] in <filename unknown>:0 | |
at System.Runtime.Serialization.ObjectManager.RaiseOnDeserializedE |
This file contains hidden or 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
type A = | |
| A of int | |
| B of string | |
> List.choose (|A|_|) [ A 3; B "foo"];; | |
List.choose (|A|_|) [ A 3; B "foo"];; | |
-------------^^^^^ | |
/vagrant/stdin(6,14): error FS0039: The value or constructor '|A|_|' is not defined |
This file contains hidden or 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
data Creep = SomeCreep | |
data Scope a = SomeScope a | |
data Scone a = AScone a | |
data Taste a = | |
Disgusting | |
| Yucky | |
| Edible | |
| Yummy | |
| Delicious |
This file contains hidden or 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
data Health = JustFine | LooksDead | IsDead | |
record Character : Type where | |
MkCharacter : (name:String) -> | |
(health:Health) -> | |
Character | |
instance Show Health where | |
show IsDead = "is dead" | |
show LooksDead = "looks dead" |
OlderNewer