(import (rnrs))
(define (derive f dx)
(lambda (x)
(/ (- (f (+ x dx))
(f x))
dx)))
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div> | |
<center> | |
<h3>Lisp.js</h3> |
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
#!/usr/bin/python | |
""" | |
Download a specific folder from a github repo: | |
gitget.py https://github.com/divs1210/kilvish/tree/master/examples/bricksnball | |
""" | |
__author__ = 'Divyansh Prakash' | |
import sys | |
import subprocess |
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
(ns transducers | |
"Learn transducers by implementing them." | |
(:refer-clojure :exclude [map filter transduce sequence])) | |
(comment | |
"Let's forget, for the sake of this experiment, about laziness in Clojure. | |
We can implement eager versions of Clojure's `map` and `filter` functions as follows:") | |
(defn map | |
[f coll] |
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
(ns maya) | |
(defmacro math-> | |
" (math-> 1 + 5 * 2 / 3) ;=> (-> 1 (+ 5) (* 2) (/ 3)) ;=> 4 " | |
[exp & f-x-pairs] | |
(if (even? (count f-x-pairs)) | |
`(-> ~exp | |
~@(for [[f x] (partition 2 f-x-pairs)] | |
(list f x))) | |
(throw (Exception. "f-x-pairs should be even.")))) |
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
(ns calculus) | |
(defonce ^:const dx 0.00001M) | |
(defn df | |
"Returns the derivative of f." | |
[f] | |
(fn [x] | |
(/ (- (f (+ x dx)) (f x)) | |
dx))) |
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
class Var(object): | |
def __init__(self, name): | |
self.name = name | |
def __repr__(self): | |
return self.name | |
class Lam(object): | |
def __init__(self, bind, expr): | |
self.bind = bind |
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
(ns futamura | |
(:require [clojure.string :as str])) | |
;; ========= util ===================== | |
(defn get-source-code [var] | |
(let [{:keys [file line]} (meta var) | |
file (slurp file) | |
lines (->> file | |
str/split-lines | |
(drop (dec line))) |
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
;; Implementation | |
;; ============== | |
(defn- return | |
[base stack] | |
(reduce (fn [acc f] | |
(f acc)) | |
base | |
stack)) | |
(defn run-fsm |