Skip to content

Instantly share code, notes, and snippets.

Susisu susisu

Block or report user

Report or block susisu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test.ts
const ref = <T>(f: (x: T) => T) => {
const r = { val: f };
return () => r;
};
const id = <T>(x: T) => x;
// r: <T>() => { val: (x: T) => T }
const r = ref(id);
// unsafe instantiations of r
const r1 = r<number>();
View poly.ts
const apply = <T, U>(f: (x: T) => U) => (x: T) => f(x);
const foo = <T extends { foo: number }>(x: T) => x.foo;
const foo2 = apply(foo); // : (x: {}) => number;
foo({ foo: 1, bar: 2 }); // OK
foo({}); // error
foo2({ foo: 1, bar: 2 }); // OK
foo2({}); // OK???
View test.hs
-- tf-random 0.5
import System.Random.TF.Gen
-- Utility functions to choose one of splitted generators.
left g = let (g', _) = split g in g'
right g = let (_, g') = split g in g'
-- Initialize a generator (the seed is not relevant).
gen = seedTFGen (0, 0, 0, 0)
-- Let `b` be the tree position bits of a generator and `bi` the index in it. Now `b` and `bi` of
View gist:a1d704f103f03704b5da071c027a4512
λ bin/bench ./gists.json 10000 pegjs
Node.js version: 10.9.0
JSON file: ./gists.json
Loops: 10000
pegjs: 56181.985ms
λ bin/bench ./gists.json 10000 parsimmon
Node.js version: 10.9.0
JSON file: ./gists.json
Loops: 10000
View what.mli
module Iterator: sig
type 'a t
type 'a result =
| Done
| Continue of 'a
val next: 'a t -> 'a result
end
View opt_parser.ts
interface IParser<T> { }
declare class Opt<K extends string, T> {
constructor(key: K, parser: IParser<T>);
}
declare const string: IParser<string>;
declare const number: IParser<number>;
declare class OptParser<P extends {}> {
View chalk.sh
#!/bin/bash
if [ $# -eq 0 ]; then
exit 0;
elif [ $# -eq 1 ]; then
printf "$@"
exit 0
fi
msg=${@: -1:1}
View 1.scala
trait SourceInfo {
type NoInfoType <: this.type
val NoInfo: NoInfoType
def showMessage(msg: String): String
}
object NoPositionInfo extends PositionInfo(NoPosition) {
override def showMessage(msg: String): String = s"${pos.toString}: $msg"
}
View seq.js
function* seq(a, b, delta = 1) {
let num = a;
let correction = 0;
while (num <= b) {
yield num;
const delta_ = delta - correction;
const next = num + delta_;
correction = (next - num) - delta_;
num = next;
}
You can’t perform that action at this time.