Skip to content

Instantly share code, notes, and snippets.

View ympbyc's full-sized avatar
💭
Lisping in the mountains.

Minori Yamashita ympbyc

💭
Lisping in the mountains.
View GitHub Profile
@ympbyc
ympbyc / 大事件ジェネレータ
Created September 29, 2011 10:22
なんかムラムラして作りました。 "ゆるゆり"の部分を任意の4文字で置き換えてください
(function (fc){
var c = fc.replace(/(.)(.)(.)(.)/, "$3っ$4っ$1っら・ら・ら・ら・$1$2$3$4、");
return c+c+c+"だ・い・じ・け・ん♪";
})("ゆるゆり")
@ympbyc
ympbyc / fact.jsl
Created October 9, 2011 03:35
JSLisp example
(define fact (lambda (x)
(if (== x 0)
1
(* x (fact (- x 1))))))
(alert (fact 5))
@ympbyc
ympbyc / fizzbuzz.scm
Created October 10, 2011 00:33
["simple answer for fizzbuzz writtern in JSLisp", "and the jscode code generated by the translator"]
(define fizzbuzz (lambda (i)
(if (== i 101)
""
(if (== (% i 15) 0)
(+ "fizzbuzz," (fizzbuzz (+ i 1)))
(if (== (% i 3) 0)
(+ "fizz," (fizzbuzz (+ i 1)))
(if (== (% i 5) 0)
(+ "buzz," (fizzbuzz (+ i 1)))
(+ (+ (String i) ",") (fizzbuzz (+ i 1))))
@ympbyc
ympbyc / fibbuzz.scm
Created October 14, 2011 01:38
fibbuzz in JSLisp
(define fib (lambda (n)
(fib_in n 0 1)))
(define fib_in (lambda (n p1 p2)
(if (== n 0)
p1
(fib_in (- n 1) (+ p1 p2) p1))))
(define fibbuzz (lambda (n)
(if (>= (= a (fib n)) 1000)
(String a)
@ympbyc
ympbyc / 0_gnomesort.jsl.scm
Created October 21, 2011 11:20
gnome sort in jslisp
(define swap (lambda (a b lis)
((. (vector) concat)
((. lis slice) 0 a)
(get lis b)
(get lis a)
((. lis slice) (+ b 1)))))
(define gnomesort (lambda (lis i)
(if (>= i (. lis length))
lis
@ympbyc
ympbyc / osakeCombinator.scm
Created November 10, 2011 16:13
Zコンビネータで酒が飲めるぞー!酒が飲める飲めるぞー!酒が飲めるぞー!
;汚い。気にしない。
(define Z (lambda (f) ((lambda (p)
(f (lambda (a) ((p p) a))))
(lambda (p)
(f (lambda (a) ((p p) a)))))))
(define sake (lambda (f)
(lambda (n)
(if (> n 12)
@ympbyc
ympbyc / Usage
Created November 24, 2011 13:18
Tweet the first line of the *terminal* buffer on double-clicks. (for nethack)
M-x term
nethack
M-x load-file
/path/to/nethackinTwitterer.el
@ympbyc
ympbyc / pythonizedlisp.py
Created December 10, 2011 06:31
リポジトリにするほどのもんでもないためgistに退避。リポジトリは消す
#!/usr/bin/python
import re
class Unbound: pass
###utilities###
def car(lst):
return lst[0]
def cdr(lst):
return lst[1:len(lst)]
@ympbyc
ympbyc / iNegaeri.js
Created December 12, 2011 04:17
寝返ったーiOS4.2+版
var prevpos = 0; //一つ前の状態を管理
var negaeri = function(e){
var x;
if (Math.abs((x = Math.floor(e.accelerationIncludingGravity.x)) - prevpos) > 5)
{
if ((prevpos < 0 && x < 0) || (prevpos > 0 && x > 0)) return;
var stat = (x > -2 && x < 2) ? "上を向いたようです" : (x < prevpos) ? "右に寝返りをうったようです" : "左に寝返りをうったようです";
prevpos = x;
var d = new Date();
var tweet = d.getHours() + "時" + d.getMinutes() + "分" + d.getSeconds() + "秒に" + stat + " #negaeri";
@ympbyc
ympbyc / oop.lisp
Created February 2, 2012 10:49
jslisp oop
(define forrange (lambda (i to fn)
(if (>= (+ i 1) to)
(fn i)
(begin (fn i)
((. arguments callee) (+ i 1) to fn)))))
(= (. Object prototype get)
(lambda (attr) (get this attr)))
(= (. Number prototype foreach)