Skip to content

Instantly share code, notes, and snippets.

@ncweinhold
ncweinhold / spellcheck2.lisp
Created February 24, 2014 19:07
Small bloom filter example based on the example at http://en.literateprograms.org/Bloom_filter_(C)
(defvar *hashfunctions* 2)
(defvar *m* 2500000)
(defvar *bloom* (make-array *m* :initial-element nil))
(defun add-word (word)
(let ((downcase-word (string-downcase word)))
(setf (elt *bloom* (mod (sax-hash downcase-word) *m*)) t)
(setf (elt *bloom* (mod (sdbm-hash downcase-word) *m*)) t)))
(defun contains-word (word)
@ncweinhold
ncweinhold / script.scm
Created March 23, 2014 15:07
Example of calling Guile scheme code from C. The scheme code can be modified without recompiling the C code.
(define simple-func
(lambda ()
(display "Script called, now I can change this") (newline)))
(define quick-test
(lambda ()
(display "Adding another function, can modify without recompilation")
(newline)
(adding-without-recompilation)))
@ncweinhold
ncweinhold / todo_react.js
Created July 3, 2017 19:18
Simple react + redux code for a todo app
const {
createStore,
bindActionCreators
} = Redux;
const {
Provider,
connect
} = ReactRedux;
const {
render
@ncweinhold
ncweinhold / trivial.cpp
Last active April 10, 2020 18:47
Trivial Example
#include <iostream>
void display_hello_world() {
std::cout << "Hello World" << std::endl;
}
int main() {
std::cout << "Silly little example" << std::endl;
display_hello_world();
@ncweinhold
ncweinhold / meta.scm
Created September 16, 2022 15:39
Metacircular Interpreter From SICP
(define apply-in-underlying-scheme apply)
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp)
(lookup-variable-value exp env))
((quoted? exp)
(text-of-quotation exp))
((assignment? exp)
(eval-assignment exp env))