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
gosh> (define-syntax for
(syntax-rules (in do)
((for var in lis do expr ...)
(let loop ((xs lis))
(if (not (null? xs))
(begin (let ((var (car xs))) expr ...)
(loop (cdr xs))))))))
#<undef>
gosh> (for x in '(1 2 3 4 5) do (print (* x x)))
1
@pasberth
pasberth / curryargs.py
Created October 18, 2011 07:19
カリー化で可変長引数っぽい事
def curryargs(arg=None, args=()):
def _ca(next=None):
return curryargs(next, args + (arg,))
if arg:
return _ca
else:
return args
def printargs(args):
for arg in args:
@pasberth
pasberth / もしかして.rb
Created November 6, 2011 02:36
こういう定義すればいいのでは!?!?!?
# -*- coding: utf-8 -*-
module Kernel
alias m_original_method_missing method_missing
def method_missing funcname, *args, &blk
if funcname.to_s =~ /^(.*?)nnn(.*?)$/
m_funcname = "#{$1}nn#{$2}"
puts "もしかして: #{m_funcname}"
puts caller
@BenHall
BenHall / happy.js
Created November 17, 2011 14:25
node-oauth not happy.
var OAuth= require('oauth').OAuth;
var events = require('events');
var http = require('http');
var eyes = require('eyes');
var _ = require('underscore');
tweet = function() {
var oAuth= new OAuth("http://twitter.com/oauth/request_token",
"http://twitter.com/oauth/access_token",
"vknnKEthhunReqNATrhjvg", "",
@yuribossa
yuribossa / update.js
Created November 22, 2011 14:32
update() with validation of Mongoose
/**
* update.js
* New update() with validation of Mongoose
*
* written by yuribossa
* https://twitter.com/yuribossa
*/
/**
* setNewUpdate
@pasberth
pasberth / dec.rb
Created November 24, 2011 07:38
デコレータ
# -*- coding: utf-8 -*-
class Module
private
def decorators
@decorators ||= []
def decorator *args, &blk
@valvallow
valvallow / christmas-tree.scm
Created December 2, 2011 14:29
christmas tree
#!/usr/local/bin/gosh
(use srfi-1)
(use util.match)
(use gauche.parseopt)
;;;
;;; - christmas tree
;;; http://parametron.blogspot.com/2010/12/blog-post.html
;;; - ansi coloring
@omegatakuma
omegatakuma / fizzbuzz.hs
Created December 14, 2011 11:12
FizzBuzz
{ - if分はスマートに書けねえ・・。
 そんなスマートじゃなくてすいません。 - }
num x = do
if x `mod` 3 == 0
then "fizz"
else if x `mod` 5 == 0
then "buzz"
else if x `mod` 15 == 0
then "fizzbuzz"
else show x
@pasberth
pasberth / ecosys.rb
Created February 10, 2012 12:43
かなり雑だけど張っておく 擬似的な生態系を作ってみる
# -*- coding: utf-8 -*-
module Ecosys
extend self
class FoodWeb
def initialize
@creatures = []
@itopoid
itopoid / hello
Created March 1, 2012 12:53
あいさつ
こんにちは。gistってたのしいね。