This file contains 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
interface = require 'interface' | |
types = require 'interface-types' | |
INumber = interface.create(n, | |
validation = (n) -> | |
# IntParse(n) or FloatParseN | |
) | |
IsomeInterface = inteface.create([ | |
{name, surname, INumber(age)} |
This file contains 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
OK = undefined | |
error_m = -> | |
is_error = ([err, val]) -> err isnt OK | |
result: (v) -> [OK, v] | |
bind: (mv, f) -> | |
if (is_error mv) then mv else (f mv[1]) |
This file contains 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 = (cb) -> | |
some_async_func1 arg1, (err, results) -> | |
(return cb err) if err | |
some_async_func2 results, (err, results2) -> | |
(return cb err) if err | |
some_async_func3 results2, (err, results3) -> | |
cb err, results3 |
This file contains 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
qsort = ([f, o...]) -> | |
return [] unless f | |
less = o.filter (i) -> i < f | |
more = o.filter (i) -> i >= f | |
qsort(less).concat([f]).concat(qsort more) |
This file contains 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
modules: | |
- build: Cafe.build | |
- minify: Cafe.minify | |
- banner: Cafe.banner | |
- wrapper: Cafe.commonjswrapper | |
build : | |
sequence: | |
""" | |
recipe <= get-recipe@build 'recipe.yaml' |
This file contains 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
-- mergesort | |
merge:: (Ord a) => [a] -> [a] -> [a] | |
merge xs [] = xs | |
merge [] ys = ys | |
merge f@(x:xs) s@(y:ys) | |
| x > y = x: merge xs s | |
| x < y = y: merge f ys | |
| x == y = x: y: merge xs ys | |
This file contains 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
-- split inversions | |
invSplit':: (Ord a) => Int -> [a] -> [a] -> ([a], Int) | |
invSplit' i xs [] = (xs, i) | |
invSplit' i [] ys = (ys, i) | |
invSplit' i f@(x:xs) s@(y:ys) | |
| x > y = | |
let (sorted, ni) = invSplit' (i + (length f)) f ys in (y: sorted, ni) | |
| x <= y = | |
let (sorted, ni) = invSplit' i xs s in (x: sorted, ni) |
This file contains 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
-- | Main entry point to the application. | |
module Main where | |
import Debug.Trace | |
import System.IO | |
-- split inversions | |
invSplit':: (Ord a) => Int -> [a] -> [a] -> ([a], Int) | |
invSplit' i xs [] = (xs, i) | |
invSplit' i [] ys = (ys, i) |
This file contains 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
qsort [] = [] | |
qsort (x:xs) = qsort less ++ [x] ++ qsort more | |
where less = filter (<x) xs | |
more = filter (>=x) xs |
This file contains 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
qsort [] = [] | |
qsort (x:xs) = qsort less ++ [x] ++ qsort more | |
where (less, more) = foldr (\el (l, m) -> if el <= x then (el:l, m) else (l, el:m)) ([], []) xs |
OlderNewer