りすと
- リスト
- になる
これは
- リストに
- なる
りすと
これは
fn main() { | |
repeat_cps(10, "hello", Box::new(|r| { | |
println!("{:?}", r) | |
})) | |
} | |
fn repeat_cps<'a, A, B>(n: i32, x: A, k: Box<Fn(A) -> B + 'a>) -> B | |
{ | |
if n == 0 { | |
k(x) |
fn main() { | |
println!("{:?}", take_while(&[1, 2, 3, 4, 5], |&x| x < 3)); | |
} | |
fn take_while<T, F>(xs: &[T], f: F) -> &[T] | |
where F: Fn(&T) -> bool | |
{ | |
let mut i = 0; | |
while f(&xs[i]) { | |
i += 1; |
/* eslint no-console: "off", no-unused-vars: "off" */ | |
var xs = [ | |
{id: 'A', pid: '', name: 'aaa'}, | |
{id: 'B', pid: '', name: 'bbb'}, | |
{id: 'C', pid: '', name: 'ccc'}, | |
{id: 'A-a', pid: 'A', name: 'aaa-aaa'}, | |
{id: 'A-b', pid: 'A', name: 'aaa-bbb'}, | |
{id: 'B-a', pid: 'B', name: 'bbb-aaa'}, | |
{id: 'B-b', pid: 'B', name: 'bbb-bbb'}, | |
{id: 'C-a', pid: 'C', name: 'ccc-aaa'}, |
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-} | |
import Data.Ratio | |
class (Num a) => Dividable a where | |
divide :: a -> a -> a | |
instance {-# INCOHERENT #-} (Integral a) => Dividable a where | |
divide = div | |
instance Dividable Double where |
fn :: [String] -> Int -> String | |
fn ~(h:t) n = if n == 0 | |
then "oops." | |
else h ++ ":" ++ show t | |
main :: IO () | |
main = putStrLn $ fn [] 0 |
"use strict" | |
const ZERO = f => x => x | |
const ONE = f => x => f(x) | |
const TWO = f => x => f(f(x)) | |
const THREE = f => x => f(f(f(x))) | |
const FOUR = f => x => f(f(f(f(x)))) | |
const FIVE = f => x => f(f(f(f(f(x))))) | |
const SUCC = n => f => x => n(f)(f(x)) |
describe "hoge" do | |
let (:hoge) {1} | |
it "first" do | |
expect(1).to eq hoge | |
end | |
describe "child" do |
var assert = require('assert'); | |
describe('hoge', function() { | |
beforeEach(function() { | |
this.foo = 1; | |
this.bar = 5; | |
THIS = this; | |
}); | |
it('first', function() { |