Divyansh Prakash, September 2023
NOTE: Please read the previous post to understand the context of this post.
Divyansh Prakash, September 2023
NOTE: Please read the previous post to understand the context of this post.
(ns sequence | |
(:refer-clojure :exclude [sequence sort]) | |
(:require [clojure.core :as core])) | |
;; Helper | |
;; ====== | |
(defn accumulate | |
([]) | |
([acc] acc) | |
([acc x] (conj (vec acc) x))) |
function mapping(f) { | |
return function(rf) { | |
return function(acc, x) { | |
return rf(acc, f(x)) | |
} | |
} | |
} | |
function filtering(f) { | |
return function(rf) { |
function getHeight(tree) { | |
return tree === null? 0: tree.height | |
} | |
function newHeight(leftSubtree, rightSubtree) { | |
return Math.max(getHeight(leftSubtree), getHeight(rightSubtree)) + 1 | |
} | |
function insert(tree, e) { | |
if(tree === null) |
// StackGC | |
// ======= | |
const StackGC = async () => null; | |
// Tests | |
// ===== | |
// util | |
function assert(assertion, msg) { | |
console.assert(assertion, `%s`, msg); |
<!DOCTYPE html> | |
<html lang="en"> | |
<title>Test React</title> | |
<head> | |
<script src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
</head> | |
<body> | |
<div id="app"></div> |
<html> | |
<head> | |
<script type="text/javascript"> | |
// Trampoline | |
// ========== | |
class Thunk { | |
constructor(f) { | |
this.f = f; | |
} | |
} |
const CLOSED = Symbol('chan-closed'); | |
const StackGC = async () => null; | |
class Chan { | |
constructor(size) { | |
this.q = []; | |
this.size = size || 1; | |
this.isClosed = false; | |
} |
import types | |
# Helpers | |
# ======= | |
def _obj(): | |
'''Dummy object''' | |
return lambda: None | |
_FILLER = _obj() |