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 iteration(op: (Double, Double) => Double, init: Int)(f: Int => Double)(a: Int, b:Int) :Double = { | |
| def iter(a: Int, result: Double) :Double = { | |
| if (a > b) result | |
| else iter(a+1, op(f(a),result)) | |
| } | |
| iter(a,init) | |
| } | |
| //def sum(f: Int => Double)(a: Int, b: Int) :Double = { | |
| // def iter(a: Int, result: Double) :Double = { |
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 factorial(n: Int) :Int = { | |
| def _factorial(n: Int, result: Int) :Int = { | |
| if (n <= 0) result else _factorial(n-1, n * result) | |
| } | |
| _factorial(n, 1) | |
| } | |
| println(factorial(10000)) | |
| def simple_factorial(n: Int) :Int = { | |
| if (n <= 0) 1 else n * simple_factorial(n-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
| import org.eclipse.swt._ | |
| import org.eclipse.swt.layout._ | |
| import org.eclipse.swt.widgets._ | |
| import org.eclipse.swt.events._ | |
| object MySWT { | |
| def main(args:Array[String]) = { | |
| val display = new Display() | |
| val shell = new Shell(display) |
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
| object Fib { | |
| def fib(n:Int) : Int = n match { | |
| case 0 => 1 | |
| case 1 => 1 | |
| case _ => fib(n-1) + fib(n-2) | |
| } | |
| def main(args:Array[String]) = { | |
| (1 to 10).foreach( n => println(fib(n))) |
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
| use strict; | |
| use warnings; | |
| package ClassA; | |
| sub initialize { "A" } | |
| package ClassB; | |
| use base qw(ClassA); | |
| sub initialize { | |
| my $class = shift; |
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
| Perl-OSX-Clipboard: Scripts to manipulate a Mac OS X-clipboard. | |
| See: null |
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
| / _ / X < ruby -pe 'gsub(/^.+;| .+$/,"")' ~/.zhistory* | sort | uniq -c | sort -r | head -20 | |
| 2245 ls | |
| 2060 git | |
| 895 cd | |
| 762 vim | |
| 529 perl | |
| 404 exit | |
| 356 curl | |
| 312 ack | |
| 136 sudo |
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
| use strict; | |
| use warnings; | |
| use Encode; | |
| use Perl6::Slurp; | |
| use Term::Encoding qw(term_encoding); | |
| use List::Util qw(shuffle); | |
| sub _shuffle_word { | |
| my $word = shift; |
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
| use strict; | |
| use warnings; | |
| use Coro::State; | |
| use Perl6::Say; | |
| my $resume; | |
| my $yield; | |
| my $func; | |
| { | |
| my $ret; |
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
| use strict; | |
| use warnings; | |
| use Coro; | |
| use Coro::Channel; | |
| use Perl6::Say; | |
| my $resume; | |
| my $yield; | |
| my $func; | |
| { |