Skip to content

Instantly share code, notes, and snippets.

@NobukazuHanada
NobukazuHanada / fizzbuzz.js
Last active September 3, 2015 04:26 — forked from kazuho/fizzbuzz.js
fizz = function f(n){
fizz = function(n){
fizz = function(n){
fizz = f;
return "Fizz";
};
return n;
};
return n;
};
# 問題: 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, ...
# という数列のn番目の数字を求める関数を書け
f = (n) -> n + 5
solve = (index)->
ret = ""
cnt = 0
while true
ret += f(cnt++)
require "./rpn"
describe "rpn" do
it "" do
expect(expr(4).("+").(3).("*").(2).("-").(1).("=")).
to eq(->(){
comp1 = 3 * 2;
comp2 = 3 + comp1;
comp3 = comp2 - 1;
return comp3 }.call)
(function (global)
{
var expr = function (n)
{
var utilities = {
"+": function (a, b) { return a + b; },
"-": function (a, b) { return a - b; },
"*": function (a, b) { return a * b; },
"/": function (a, b) { return a / b; }
(function (global)
{
var expr = function (n)
{
var utilities = {
"+": function (a) { return function(b){ return a + b; } },
"-": function (a) { return function(b){ return a - b; } },
"*": function (a) { return function(b){ return a * b; } },
"/": function (a) { return function(b){ return a / b; } }
(function ()
{
function partial(fun)
{
var _slice = [].slice,
args = _slice.call(arguments);
args.shift();
return function ()
{
return fun.apply(this, args.concat(_slice.call(arguments)));