Skip to content

Instantly share code, notes, and snippets.

ncweinhold / meta.scm
Created Sep 16, 2022
Metacircular Interpreter From SICP
View meta.scm
(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))
ncweinhold / trivial.cpp
Last active Apr 10, 2020
Trivial Example
View trivial.cpp
#include <iostream>
void display_hello_world() {
std::cout << "Hello World" << std::endl;
int main() {
std::cout << "Silly little example" << std::endl;
ncweinhold / todo_react.js
Created Jul 3, 2017
Simple react + redux code for a todo app
View todo_react.js
const {
} = Redux;
const {
} = ReactRedux;
const {
ncweinhold / script.scm
Created Mar 23, 2014
Example of calling Guile scheme code from C. The scheme code can be modified without recompiling the C code.
View script.scm
(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")
ncweinhold / spellcheck2.lisp
Created Feb 24, 2014
Small bloom filter example based on the example at
View spellcheck2.lisp
(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)
View spellcheck.lisp
;; This is based on the solution given here
;; just ported to common lisp
(defvar *k* 7)
(defvar *m* 1000000)
(defvar *bloom* (make-array *m* :initial-element nil))
(defun key (i word)
(let* ((c (string (code-char (+ i 96))))
ncweinhold / main.go
Created Jun 10, 2012
Dabbling with Go
View main.go
package main
import (
func main() {
http.HandleFunc("/", indexHandler)
http.HandleFunc("/about", aboutHandler)
ncweinhold / gist:1062572
Created Jul 3, 2011
Dabbling with Tornado
View gist:1062572
import sqlite3
import os.path
import tornado.httpserver
import tornado.ioloop
import tornado.web
class TestApplication(tornado.web.Application):
def __init__(self):
handlers = [
ncweinhold / gist:1011280
Created Jun 6, 2011
different ways of summing lists of numbers
View gist:1011280
#lang racket
(define (my-sum-1 lst)
((null? lst) 0)
(else (+ (car lst) (my-sum-1 (cdr lst))))))
(define (my-sum-2 lst)
(define (my-sum-iter res lst)
ncweinhold /
Created May 30, 2011
curses snake WIP
import curses
import time
class Direction(object):
class Position(object):