This file contains hidden or 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
| const script = document.createElement('script'); | |
| script.type = 'text/javascript'; | |
| script.innerHTML = 'throw new Error("テスト")'; | |
| document.body.appendChild(script); |
This file contains hidden or 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
| const assert = require('assert'); | |
| const deepEqual = assert.deepEqual; | |
| const isFizz = x => x % 3 === 0; | |
| const isBuzz = x => x % 5 === 0; | |
| const isFizzBuzz = x => isFizz(x) && isBuzz(x); | |
| const match = x => { | |
| if (isFizzBuzz(x)) return 'FizzBuzz'; |
This file contains hidden or 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
| #![feature(no_std)] | |
| #![feature(conservative_impl_trait)] | |
| pub trait Foo { | |
| fn get_foo(&self) -> i32; | |
| } | |
| struct ImplFoo(i32); | |
| impl Foo for ImplFoo { |
This file contains hidden or 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 main() { | |
| let foo = "bar"; // 変数束縛(≠ 代入 関数型言語の束縛とも違う) | |
| let foo_1: i32 = 100; // 静的型付け | |
| // 関数宣言 | |
| fn bar(x: i32) -> i32 { | |
| x + 100 // ブロックの最後の行がreturnされる | |
| } |
This file contains hidden or 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
| pub fn use_after_move() { | |
| let v = vec![1, 2, 3]; | |
| let v2 = v; | |
| println!("{:?}", v); | |
| } | |
| pub fn use_after_copy() { | |
| let v = 0; | |
| let v2 = v; | |
| println!("{:?}", v2); |
This file contains hidden or 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
| // #![no_std] | |
| pub trait Foo { | |
| fn sum(&self, x: i32, y: i32) -> i32; | |
| } | |
| struct FooInstance; | |
| impl Foo for FooInstance { | |
| fn sum(&self, x: i32, y: i32) -> i32 { |
This file contains hidden or 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
| #![no_std] | |
| pub trait Foo { | |
| fn sum(&self, x: i32, y: i32) -> i32; | |
| } | |
| struct FooInstance; | |
| impl Foo for FooInstance { | |
| fn sum(&self, x: i32, y: i32) -> i32 { |
This file contains hidden or 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
| String file contents |
This file contains hidden or 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
| // @flow | |
| type FlowFn<T> = (x: T) => T; | |
| const pipe = <T>(...fns: FlowFn<T>[]) => (seed: T): T => fns.reduce((acc, fn) => fn(acc), seed); | |
| const multiply = (x: number) => x * 2; | |
| const piped = pipe( | |
| multiply, | |
| multiply, |
This file contains hidden or 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
| import { CurriedFunction2 } from 'ramda'; | |
| declare module 'ramda-fantasy' { | |
| declare interface IFuture<E, A> { | |
| fork(reject: (v: E) => void, resolve: (v: A) => void): void; | |
| ap(f: any): any; | |
| map<A2>(fb: (e: A) => A2): IFuture<E, A2>; | |
| bimap<E2, A2>(errFn: (value: E) => E2, successFn: (value: A) => A2): IFuture<E2, A2>; | |
| chain<A2>(fn: (v: A) => IFuture<E, A2>): IFuture<E, A2>; | |
| chainReject<A2>(fn: (value: E) => IFuture<E, A2>): IFuture<E, A2>; |