> npm install babel-preset-es2015
> npm install babel-polyfill
> babel-node --presets "es2015" evenfib.js
4613732
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
(defn nn [s] (->> s (partition-by identity) (mapcat (juxt count first)))) | |
(defn ant [] (iterate nn [1])) | |
(-> (ant) (nth 1000000) (nth 1000000)) |
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
package main | |
import "fmt" | |
type genf func(chan<- uint8) | |
func gen(f genf) <-chan uint8 { | |
c := make(chan uint8) | |
go f(c) | |
return 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
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
module Lib | |
( | |
kMeans | |
) where | |
import GHC.Exts (groupWith) | |
import Data.List (transpose, sort) | |
import Data.List.Split (chunksOf) |
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
// | |
// main.c | |
// ant | |
// | |
// Created by Jooyung Han on 1/31/16. | |
// Copyright © 2016 Jooyung Han. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <stdlib.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
/* | |
============================================================================ | |
Name : Buffer.c | |
Author : Jooyung Han | |
Version : | |
Copyright : | |
Description : Hello World in C, Ansi-style | |
============================================================================ | |
*/ |
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
// http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#lazyinstrict | |
class Cons<A, B> { | |
head: A; | |
tail: B; | |
constructor(head: A, tail: B) { | |
this.head = head; | |
this.tail = tail; | |
} | |
} | |
function cons<A, B>(head: A, tail: B): Cons<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
/* base functions */ | |
function apply(f,args) { | |
return f.apply(undefined, args); | |
} | |
var slice = Function.prototype.call.bind(Array.prototype.slice); | |
/* Stream */ |
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 PEG = require('pegjs'); | |
var parser = PEG.buildParser(` | |
tree = fork? | |
fork = name:[a-z] c:children? { return Object.assign({name}, c); } | |
children = '(' left:tree ',' right:tree ')' {return {left,right}} | |
`); | |
var tree = parser.parse('a(b,c(,d))'); | |
console.log(tree); |
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
/* | |
Using following two API functions | |
- deletePage(pageId, callback) : delete a page. if the page has sub-pages then it fails. | |
- getChildPages(pageId, callback) : get a list of ids of direct child pages. | |
write deleteTree(pageId, callback) function which | |
deletes the pages of pageId and sub-pages. |