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
(use gauche.generator) | |
(use gauche.lazy) | |
(define-syntax chain | |
(syntax-rules () | |
[(_ lis proc ...) | |
(let loop ([p (map (lambda (p) | |
(append `(pa$) p)) | |
(list `proc ...))] | |
[l lis]) |
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
public static class Values { | |
public static void Receive<T1, T2>(this Tuple<T1, T2> tuple, out T1 item1, out T2 item2) { | |
item1 = tuple.Item1; | |
item2 = tuple.Item2; | |
} | |
public static void CallWith<T1, T2>(this Tuple<T1, T2> tuple, Action<T1, T2> func) { | |
func(tuple.Item1, tuple.Item2); | |
} | |
} |
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
#!/usr/bin/env gosh | |
(use gauche.threads) | |
(use gauche.partcont) | |
(define (display-current-thread comment) | |
(display (format "~a (~a)\n" comment (current-thread)))) | |
(display-current-thread "Start") |
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
private delegate Func<A, R> Recursive<A, R>(Recursive<A, R> r); | |
public static Func<A, R> Y<A, R>(Func<Func<A, R>, Func<A, R>> f) { | |
return ((Recursive<A, R>)(r => a => f(r(r))(a)))((Recursive<A, R>)(r => a => f(r(r))(a))); | |
} |
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
@ test.php (chmod +x test.php) | |
#!/usr/bin/php | |
<?php | |
echo 'test'; | |
@ test2.php | |
<?php | |
system('./test.php'); |
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
$.fn.extend({ | |
sideEffect: function(func) { | |
func.apply(this); | |
return this; | |
} | |
}); | |
$('<div />') | |
.append('<img src="hoge.png" />') | |
.append($('<span />') |
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://www.shido.info/lisp/scheme_amb.html | |
SICP の問題 4.42. を解いてみましょう。問題は以下の通りです: | |
5人の女子生徒が試験を受けた。彼女らの両親は結果に対し過度の関心を持っている、と彼女らは考えている。 そこで彼女らは自宅へ試験についての手紙を書くのに、誰もが1つの正しい情報と1つのうその情報を書こうと 約束した。以下は彼女らの手紙の関係する部分である。 | |
Betty: 「Kitty は試験が2番で私は3番でした。」 | |
Ethel: 「私がトップと聞いてうれしいでしょう。Joan が2ばんでした。」 | |
Joan: 「私は3番でした。可哀想な Ethel はビリでした。」 |
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
new[] { 1, 2, 3, 4, 5 } | |
.Join(new[] { 1, 2, 3, 4, 5 }, _ => 1, _ => 1, (i, j) => new { i, j }) | |
.Join(new[] { 1, 2, 3, 4, 5 }, _ => 1, _ => 1, (ij, k) => new { i = ij.i, j = ij.j, k }) | |
.Where(v => (v.i + v.j + v.k) % 10 == 0) | |
.Run(Console.WriteLine) | |
; | |
/* | |
{ i = 1, j = 4, k = 5 } | |
{ i = 1, j = 5, k = 4 } |
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
Observable.FromEvent<KeyEventArgs>(this, "KeyDown") | |
.BufferWithTimeOrCount(TimeSpan.FromMilliseconds(2000), 6) | |
.Select(keys => keys.Select(key => key.EventArgs.KeyCode)) | |
.Where(keys => keys.SequenceEqual(new[] { Keys.K, Keys.O, Keys.N, Keys.M, Keys.A, Keys.I })) | |
.Repeat() | |
.Subscribe(_ => MessageBox.Show("Hit !")) | |
; |
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
private void Form1_Load(object sender, EventArgs e) { | |
var down = Observable.FromEvent<MouseEventArgs>(this, "MouseDown"); | |
var move = Observable.FromEvent<MouseEventArgs>(this, "MouseMove"); | |
var up = Observable.FromEvent<MouseEventArgs>(this, "MouseUp"); | |
var diff = move | |
.SkipUntil(down) | |
.TakeUntil(up) | |
.Let(m => m.Zip(m.Skip(1), (l, r) => new { Left = l, Right = r })) | |
.Repeat() |