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
(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)])) |
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
(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) |
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
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... |
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
(= (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))) |
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
;;; there is no need for type Bool | |
(= (true a a a) | |
x y x) | |
(= (false a a a) | |
x y y) | |
;;; Twisted algebraic datatype |
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
/* | |
* thunk ~= promise | |
* thunkのforceは別スレッド (投機的実行) | |
*/ | |
function Thunk (thunk) { | |
this.thunk = thunk; | |
this.val = null; | |
this.ff = []; | |
} |
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
(data (list a) | |
(cons a (list a)) | |
nil) | |
(data (tree a) | |
(node a (forest a))) | |
(data (forest a) | |
(list (tree 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
(define (print-code fmt code) | |
(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)) |
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
(= -> x f g (g (f x))) | |
(-> 0 | |
(+ 2) | |
-> (* 3) | |
-> num->str | |
-> (flip ++ " = six") | |
(print 0)) | |
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
fs = require 'fs'; | |
readFile = (fname) -> | |
fs.readFileSync fname, encoding: "utf8" | |
print = (str) -> | |
console.log str | |
null |