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
| let fibonacci n = | |
| let rec fib_cps n cont = | |
| match n with | |
| | 0 -> (cont 0) // <-- even the base cases need to keep the promise | |
| | 1 -> (cont 1) | |
| | _ -> (fib_cps (n-1) (fun a -> fib_cps (n-2) (fun b -> cont(a+b)) ) ) | |
| fib_cps n (fun x -> x) // <- this anon function is our base continuation |
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
| let fibonacci n = | |
| let rec loop current a b = | |
| if current == n | |
| then a + b | |
| else loop (current+1) b (a+b) | |
| match n with | |
| | 0 -> 0 | |
| | 1 -> 1 | |
| | _ -> loop 2 0 1 |
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
| let rec fibonacci n = | |
| match n with | |
| | 0 -> 0 | |
| | 1 -> 1 | |
| | _ -> (fibonacci (n-1)) + (fibonacci (n-2)) |
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
| require 'rubygems' | |
| require 'spec' | |
| require 'spec/autorun' | |
| @watches = [] | |
| def watch(matcher, &block) | |
| @watches << Matcher.new(matcher, &block) | |
| end | |
| def do_a_loop(sender, arg) | |
| puts "found a #{arg.change_type} with #{arg.name}" |
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 expression = | |
| | Empty | |
| | Number of int | |
| let expression stream = | |
| match stream with | |
| | [] -> Empty, stream | |
| | h::t -> Number( Int32.Parse(h)), t | |
| let evaluate expr = | |
| match expr with | |
| | Empty -> 0 |
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 DisposableHero | |
| include System::IDisposable | |
| attr :name | |
| def initialize(name = "Jed") | |
| @name = name | |
| end | |
| def do_something_to(other) | |
| puts "#{@name} washes a car for #{other.name}" | |
| end | |
| def do_something |
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
| require 'xamltools.rb' | |
| class MyCommand | |
| include System::Windows::Input::ICommand | |
| def add_CanExecuteChanged(h) | |
| @change_handlers << h | |
| end | |
| def remove_CanExecuteChanged(h) | |
| @change_handlers.remove(h) | |
| 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
| require 'xamltools.rb' | |
| require 'PresentationFramework' | |
| class ViewModel | |
| attr :greeting, true | |
| def initialize(greet) | |
| @greeting = greet | |
| 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
| require 'rubygems' | |
| require 'builder' | |
| require 'PresentationCore' | |
| require 'PresentationFramework' | |
| require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeytoken=b77a5c561934e089' | |
| module XamlTools | |
| include System::Windows | |
| StringReader = System::IO::StringReader; | |
| XamlReader = System::Windows::Markup::XamlReader |
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
| require 'rubygems' | |
| require 'builder' | |
| require 'PresentationCore' | |
| require 'PresentationFramework' | |
| require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeytoken=b77a5c561934e089' | |
| include System::Windows | |
| StringReader = System::IO::StringReader; | |
| XamlReader = System::Windows::Markup::XamlReader | |
| XmlReader = System::Xml::XmlReader; |