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
public class KdTree { | |
private Node root; | |
private static final boolean X = true; | |
private static final boolean Y = false; | |
private class Node { | |
private Point2D p; |
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 of Spaceship - program template for RiceRocks | |
import simplegui | |
import math | |
import random | |
# globals for user interface | |
WIDTH = 800 | |
HEIGHT = 600 | |
score = 0 | |
lives = 3 |
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
# University of Washington, Programming Languages, Homework 7, hw7.rb | |
# (See also ML code) | |
# a little language for 2D geometry objects | |
# each subclass of GeometryExpression, including subclasses of GeometryValue, | |
# needs to respond to messages preprocess_prog and eval_prog | |
# | |
# each subclass of GeometryValue additionally needs: | |
# * shift |
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
# University of Washington, Programming Languages, Homework 6, hw6runner.rb | |
# This is the only file you turn in, so do not modify the other files as | |
# part of your solution. | |
class MyPiece < Piece | |
# The constant All_My_Pieces should be declared here | |
All_My_Pieces = [[[[0, 0], [1, 0], [0, 1], [1, 1]]], # square (only needs one) | |
rotations([[0, 0], [-1, 0], [1, 0], [0, -1]]), # T | |
[[[0, 0], [-1, 0], [1, 0], [2, 0]], # long (only needs two) |
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
;; Programming Languages, Homework 5 | |
#lang racket | |
(provide (all-defined-out)) ;; so we can put tests in a second file | |
;; definition of structures for MUPL programs - Do NOT change | |
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo") | |
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17) | |
(struct add (e1 e2) #:transparent) ;; add two expressions | |
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4 |
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
#lang racket | |
(provide (all-defined-out)) ;; so we can put tests in a second file | |
;; put your code below | |
(define sequence | |
(lambda (low high stride) | |
(if (> low high) |
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
(* Coursera Programming Languages, Homework 3, Provided Code *) | |
exception NoAnswer | |
datatype pattern = Wildcard | |
| Variable of string | |
| UnitP | |
| ConstP of int | |
| TupleP of pattern list | |
| ConstructorP of string * pattern |
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
(* Dan Grossman, Coursera PL, HW2 Provided Code *) | |
(* if you use this function to compare two strings (returns true if the same | |
string), then you avoid several of the functions in problem 1 having | |
polymorphic types that may be confusing *) | |
fun same_string(s1 : string, s2 : string) = | |
s1 = s2 | |
(* put your solutions for problem 1 here *) |
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
fun is_older(date1 : int*int*int, date2: int*int*int) = | |
if #1 date1 <> #1 date2 | |
then | |
if #1 date1 < #1 date2 | |
then true | |
else false | |
else | |
if #2 date1 <> #2 date2 | |
then | |
if #2 date1 < #2 date2 |