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
| var noflo = require('noflo'); | |
| var fbp = require('fbp'); | |
| var fs = require('fs'); | |
| var path = require('path'); | |
| var util = require('util'); | |
| var browserify = require('browserify'); | |
| var coffeeify = require('coffeeify'); | |
| var through = require('through2'); | |
| var stream = require('stream'); | |
| var wait = require('wait.for'); |
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
| -- | Garden variety prime sieve | |
| isPrime x = not $ any divisible $ takeWhile bounded [2..] where | |
| divisible y = x `mod` y == 0 | |
| bounded y = y * y <= x | |
| -- | Germain prime sieve | |
| isGermainPrime x = (isPrime x) && (isPrime (2*x + 1)) | |
| -- | All of the Germain primes |
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
| // this is the "generated" code (loading from fs is still 'generating'...) | |
| module.exports = function() { console.log('hello world'); } |
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
| trait Arrow<B, C> { | |
| fn apply(&self, B) -> C; | |
| } | |
| impl<'a, B, C> Arrow<B, C> for 'a |B| -> C { | |
| fn apply(&self, b: B) -> C { (*self)(b) } | |
| } | |
| fn compose<A, B, C>(g: &Arrow<B, C>, f: &Arrow<A, B>) -> ~Arrow<A, C> { | |
| ~|a: A| -> C { g.apply(f.apply(a)) } as ~Arrow<A, C> |
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
| trait Arrow<B, C> { | |
| fn call(&self, B) -> C; | |
| fn compose<A, G: Arrow<A, B>, H: Arrow<A, C>>(&self, G) -> H; | |
| } |
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
| trait Arrow<A, B> { } | |
| trait Category { | |
| fn id<A, F: Arrow<A, A>>() -> F; | |
| //fn compose<A, B, C, F: Arrow<A, B>, G: Arrow<B, C>, H: Arrow<A, C>>(f: F, g: G) -> H; | |
| } | |
| /* closures */ | |
| impl<'a, A, B> Arrow<A, B> for 'a |A| -> B { } |
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
| trait Category<S, T> { | |
| fn id<A, AA: Category<A, A>>() -> AA; | |
| fn compose<A, B, C, AB: Category<A, B>, BC: Category<B, C>, AC: Category<A, C>>(BC, AB) -> AC; | |
| } | |
| impl<'a, S, T> Category<S, T> for ('a |S| -> T) { | |
| fn id<A, |A| -> A>() -> ('a |A| -> A) { | |
| |a: A| -> A { a } | |
| } |
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
| struct Thing { ... } | |
| struct Collection { things: ~[~Thing] } | |
| impl Collection { | |
| fn get_thing(&self) -> Thing<$self> { ... } | |
| fn get_other_thing(&self) -> Thing<$self> { ... } | |
| fn compare(t1: Thing<$a>, t2: Thing<$a>) -> uint { ... }; | |
| } | |
| fn foo(c1: Collection, c2: Collection) -> uint { |
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
| use std::libc::*; | |
| #[link_args="src/httpparser/http_parser.c src/httpparser/stubs.c"] | |
| extern { | |
| fn http_parser_version() -> c_ulong; | |
| fn http_parser_stubs_alloc() -> HttpParserPtr; | |
| } | |
| #[fixed_stack_segment] | |
| #[inline(never)] |
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
| use std::iterator::{Peekable}; | |
| fn accept<T: Iterator<char>>(it: &mut Peekable<char, T>, c: char) -> bool { | |
| if *(it.peek().unwrap()) == c { | |
| it.next(); | |
| return true; | |
| } | |
| return false; | |
| } |