Skip to content

Instantly share code, notes, and snippets.

@jbclements
jbclements / k-cfa.rkt
Created May 23, 2018 16:05
Matthew Might's toy/illustrative k-CFA implementation
#lang racket
;; A simple implementation of k-CFA.
;; Author: Matthew Might (translated by Jay McCarthy)
;; Site: http://matt.might.net/
;; k-CFA is a well-known hierarchy of increasingly precise
;; control-flow analyses that approximate the solution to the
;; control-flow problem.
@jbclements
jbclements / interp.rkt
Created April 23, 2018 16:07
An interpreter for the consieuten language of milestone 2
#lang typed/racket
(require "ir.rkt")
(define-type Value (U Integer Boolean Closure))
(define-type Env (HashTable Symbol (Boxof Value)))
(struct Closure ([params : (Listof Symbol)]
[body : Prog]
[env : Env])
#:transparent)
==> default: warning: Could not load fact file /tmp/vagrant-puppet/modules-81dadcc86aebb4f5a1b81aa09a8166ab/apt/lib/facter/apt_updates.rb: ./apt_updates.rb:36: syntax error, unexpected ':', expecting kEND
==> default: confine osfamily: 'Debian'
==> default: ^
==> default: ./apt_updates.rb:41: syntax error, unexpected ':', expecting kEND
==> default: confine osfamily: 'Debian'
==> default: ^
==> default: ./apt_updates.rb:46: syntax error, unexpected ':', expecting kEND
==> default: confine apt_has_updates: true
==> default: ^
==> default: ./apt_updates.rb:57: syntax error, unexpected ':', expecting kEND
@jbclements
jbclements / parser.rkt
Last active April 22, 2018 01:54
A simple racket parser for Assignment 2. It's in slightly better shape?
#lang racket
;; this is the consieuten parser
(require parser-tools/lex
(prefix-in : parser-tools/lex-sre)
parser-tools/yacc)
;; token definitions:
((λ (dividesP)
((λ (prime_loop)
((λ (isPrimeP)
((λ (loop) ((loop loop) 10000))
(λ (loop)
(λ (n)
(ifleq0
(+ n (* -1 2))
(ifleq0
(+ 2 (* -1 n))
name: Assignment 1 Captain Teach
id: a1-ct
description: Problem 3.3.3 Solution
steps:
- id: tests
instructions: "Submit your solution to problem 3.3.3"
reviews:
- student-submission:
id: student-reviews
amount: 2
pcp074832pcs:~/plt (git)-[master]- clements> time make CPUS=3
if [ "3" = "" ] ; \
then /Applications/Xcode.app/Contents/Developer/usr/bin/make plain-in-place PKGS="main-distribution main-distribution-test" ; \
else /Applications/Xcode.app/Contents/Developer/usr/bin/make cpus-in-place CPUS="3" PKGS="main-distribution main-distribution-test" ; fi
/Applications/Xcode.app/Contents/Developer/usr/bin/make -j 3 plain-in-place JOB_OPTIONS="-j 3" PKGS="main-distribution main-distribution-test"
/Applications/Xcode.app/Contents/Developer/usr/bin/make base
mkdir -p build/config
echo '#hash((links-search-files . ()))' > build/config/config.rktd
mkdir -p racket/src/build
/Applications/Xcode.app/Contents/Developer/usr/bin/make racket/src/build/Makefile
Process: racket [73045]
Path: /Users/USER/*/racket
Identifier: racket
Version: 0
Code Type: X86-64 (Native)
Parent Process: make [66951]
Responsible: Terminal [352]
User ID: 501
Date/Time: 2015-10-20 08:48:24.963 -0700
@jbclements
jbclements / qsort-store-passing-style.rkt
Created May 8, 2015 23:57
This version of the file also performs an in-place imperative quicksort... but using store-passing style!
#lang plai-typed
#;(require rackunit)
(require (typed-in
racket (round : (number -> number))))
;; let's implement quicksort. Using mutation.
;; a store is a map from numbers to numbers
@jbclements
jbclements / qsort-with-mutation-original.rkt
Created May 8, 2015 23:53
This version of the file performs an in-place iterative quicksort on a mutable vector.
#lang plai-typed
#;(require rackunit)
(require (typed-in
racket (round : (number -> number))))
;; let's implement quicksort. Using mutation.