Skip to content

Instantly share code, notes, and snippets.

View ympbyc's full-sized avatar
💭
Lisping in the mountains.

Minori Yamashita ympbyc

💭
Lisping in the mountains.
View GitHub Profile
@ympbyc
ympbyc / test-seq-fns.clj
Last active November 28, 2016 01:59
It worked!
(ns cljs.core.typed.test.ympbyc.cljs-core
(:require-macros [cljs.core.typed :refer [ann] :as ct])
(:require [cljs.core.typed :refer [All U IFn]]
[cljs.core :refer [IVector ISeq]]))
(ann cljs.core/seq (All [x] [(U (ISeq x) (IVector x)) -> (ISeq x)]))
(ann cljs.core/first
(All [x] [(U (ISeq x) (IVector x)) -> (U nil x)]))
@ympbyc
ympbyc / carrot-idea.carrot.lisp
Last active January 3, 2016 19:59
Type system idea for Carrot.
(interface ICallable
(as-function a (Fn b c)))
(interface IBool ICallable
(if IBool a a a))
(implements True IBool
true)
(= (if True a a a)
_ then else then)
@ympbyc
ympbyc / FACTR.lol
Last active January 3, 2016 09:09
I IZ FACTR YR NUMBR. Factorial in LOLCODE.
HAI 1.2
BTW I CAN COMPUTES FACTORIAL
HOW IZ I FACTR YR X
BOTH SAEM X AN 0
O RLY?
YA RLY
FOUND YR 1
NO WAI
FOUND YR PRODUKT OF X AN...
@ympbyc
ympbyc / coffee-cup.carrot.lisp
Last active January 1, 2016 10:29
CoffeeCup in Carrot
(= (cup Number CupState) n n)
(= (broken-cup CupState) nil)
(= (fill Number CupEvent) n (cons 'fill n))
(= (spill Number CupEvent) n (cons 'spill n))
(= (drop CupEvent) (cons 'drop nil))
(= (next-cup-state CupEvent CupState CupState)
ce cs
(=? (fst ce) 'fill (cup (+ cs (snd ce)))
@ympbyc
ympbyc / functionaltype.carrot.scm
Last active December 30, 2015 17:59
Typing Lambda Calculus & Generic Function & MOP
;;; there is no need for type Bool
(= (true a a a)
x y x)
(= (false a a a)
x y y)
;;; Twisted algebraic datatype
/*
* thunk ~= promise
* thunkのforceは別スレッド (投機的実行)
*/
function Thunk (thunk) {
this.thunk = thunk;
this.val = null;
this.ff = [];
}
@ympbyc
ympbyc / adt.nadeko
Last active December 29, 2015 04:59
ADT
(data (list a)
(cons a (list a))
nil)
(data (tree a)
(node a (forest a)))
(data (forest a)
(list (tree a)))
@ympbyc
ympbyc / graph.scm
Last active December 29, 2015 04:49
Graph Rewriting
(define (print-code fmt code)
(print
(regexp-replace-all #/#<closure\s(.+?)>/ (format fmt code) "\\1")))
(define (root xs) (car xs))
(define (forest xs) (cdr xs))
(define (tree? xs) (pair? xs))
(define (tree root . forest)
(cons root forest))
@ympbyc
ympbyc / pipeline.nadeko.lisp
Last active December 28, 2015 15:29
Pipeline operator as a function
(= -> x f g (g (f x)))
(-> 0
(+ 2)
-> (* 3)
-> num->str
-> (flip ++ " = six")
(print 0))
@ympbyc
ympbyc / iom.coffee
Last active December 27, 2015 20:09
fs = require 'fs';
readFile = (fname) ->
fs.readFileSync fname, encoding: "utf8"
print = (str) ->
console.log str
null