- にゃん
- わん
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
package main | |
import ( | |
"bufio" | |
"code.google.com/p/portaudio-go/portaudio" | |
"errors" | |
"fmt" | |
"os" | |
"strconv" | |
"strings" |
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
sub nyan { | |
# $_[0] で第一引数にアクセ | |
$_[0] = 2; | |
} | |
my $i = 1; | |
nyan($i); | |
print $i; # => 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
string = "nyan" | |
def hoge(s) | |
s.gsub!("n", "") | |
end | |
hoge(string) | |
p string # => ya |
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 IntWrapper | |
attr_accessor :i | |
def initialize(i) | |
@i = i | |
end | |
end | |
nyan = IntWrapper.new(1) | |
def hoge(wrapper) | |
wrapper.i = 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
import scala.language.implicitConversions | |
// FlipFlap型クラスを定義 | |
trait FlipFlap[T] { | |
// このメソッドはアドホック多相を実現する | |
def flipFlap(x: T): T | |
} | |
// Int をFlipFlap型クラスの型インスタンスとして定義 | |
implicit val intFlipFlap = new FlipFlap[Int] { |
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 erasure のせいでメソッドのオーバーロードができない | |
// 以下のようなコンパイルエラーになる | |
// | |
// error: double definition: | |
// method nyan:(x: Option[Boolean])Int and | |
// method nyan:(x: Option[Int])Int at line 2 | |
// have same type after erasure: (x: Option)Int | |
def nyan(x: Option[Int]) = 0 | |
def nyan(x: Option[Boolean]) = 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
var Nyan = (function () { | |
function Nyan() { | |
this.nyan = "nyan"; | |
} | |
Nyan.prototype.functionStyle = function () { | |
return function () { | |
return this.nyan; | |
}; | |
}; |
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
function compose(f, g) { | |
return function(x){ | |
return g(f(x)); | |
} | |
} | |
var increment = function(x) { | |
return x + 1; | |
} | |
var decrement = function(x) { |
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
function flip(f){ | |
return g; // flip' f = g | |
function g(x, y){ // where g x y = f y x | |
return f(y, x) | |
} | |
} | |
function nyan(a, b) { | |
console.log(a); |