Skip to content

Instantly share code, notes, and snippets.

@McTano
McTano / lisp-diff.rkt
Created February 2, 2021 23:23
Program to compare symbolic expressions in lisp
;; see the README at:
;; https://github.com/mctano/lisp-diff
#! /usr/bin/racket
#lang racket
(require rackunit)
(require plai/datatype)
(provide (rename-out [display-diff display-lisp-diff])
)
;; Constants

Notes on the README

  • The sections should be organized in terms of getting the server running instead of as technical steps. i.e. "How to Run the Server". The steps for that should go at the top, because that's what most devs will want to do.

  • Currently the commands for actually running the server are under "Get a GHC Based Development Shell", right?

  • I don't think we need the instructions on how to do each thing manually in each section. If someone wants to know how it's done, they can look at the Makefile. Or if the steps aren't the same as what the makefile does, maybe we could put these in another file to keep the README simpler.

  • Why do we need two different dev shells? Is that because we can't have the dependencies for both the client and the server at the same time. What is actually made available in each? Just the compilers? This could be explained more.

  • We should rename the make commands in terms of what we're building instead of the compiler used. build-client and build-server were be

--Exercises:
--1
SELECT editions.isbn FROM publishers JOIN editions
ON publishers.id = editions.publisher_id
WHERE publishers.name = 'Random House';
--2
module Flight
def fly
"I'm a #{self.class}, I'm flying!"
end
end
class Animal
def initialize
@num_legs = 4
end
def add_tax(cost, tax_rate)
price + (price * tax_rate)
end
def sign_cost(height, width, color_count)
subtotal = height * width * 15
color_modifier = (color_count <= 2) ? 10 : 15
subtotal += subtotal * color_modifier
total = add_tax(subtotal, 0.15)
@candidates = [
{
id: 5,
years_of_experience: 4,
github_points: 293,
languages: ['C', 'Ruby', 'Python', 'Clojure'],
date_applied: 5.days.ago.to_date,
age: 26
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
def has_sin?(string)
!(string !~ /(?<=\D|^)(\d{3}-\d{3}-\d{3})(?=\D|$)/)
end
puts "has_sin? returns true if it has what looks like a SIN"
puts has_sin?("please don't share this: 234-604-142") == true
puts "has_sin? returns false if it doesn't have a SIN"
def bottles_purchased
money_redeemed = @money - (@money % 2)
empties_redeemed = @empties - (@empties % 2)
caps_redeemed = @caps - (@caps % 4)
@money -= money_redeemed
@total_money_redeemed += money_redeemed
@empties -= empties_redeemed
@total_empties_redeemed += empties_redeemed
NUMERALS = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
LX: 40,
X: 10,
# @states = {
# OR: 'Oregon',
# FL: 'Florida',
# CA: 'California',
# NY: 'New York',
# MI: 'Michigan'
# }
# # Task 1
# @states[:MN] = 'Minnesota'