Skip to content

Commit

Permalink
first commit, delete original .git and reinitialize
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilliamson1 committed Nov 30, 2016
0 parents commit 58c0638
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
127 changes: 127 additions & 0 deletions SchemerNums.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#lang racket
;string functions
(define firsts
(lambda (l)
(cond
[(null? l)(quote())]
[else (cons (car (car l))
(firsts (cdr l)))])))

(define atom?
(lambda (x)
(and (not (pair? x)) (not (null? x)))))
;lat returns true if l is a list of atoms
(define lat?
(lambda (l)
(cond
[(null? l) #t]
[(atom? (car l)) (lat? (cdr l))]
[else #f]
)))
;number functions
(define add1
(lambda (n)
(+ n 1)))

(define sub1
(lambda (n)
(- n 1)))

(define add
(lambda (n m)
(cond
[(zero? m) n]
[else (add1 (add n (sub1 m)))]
)))

(define subt
(lambda (n m)
(cond
[(zero? m) n]
[else (sub1 (subt n (sub1 m)))]
)))

(define multi
(lambda (n m)
(cond
[(zero? m) 0]
[else (+ n (multi n (sub1 m)))]
)))

(define divi
(lambda (n m)
(cond
[(zero? m) 0]
[(< (subt n m) 0) 0]
[(<= n 0) 0]
[else (add1 (div (subt n m) m))])))



(define length
(lambda (lat)
(cond
[(null? lat) 0]
[else (add1(length(cdr lat)))])))

(define pick
(lambda (n lat)
(cond
[(zero? (sub1 n))(car lat)]
[else (pick (sub1 n)(cdr lat))])))

(define tup+
(lambda (tup1 tup2)
(cond
[(and(null? tup1)(null? tup2)) (quote ())]
[(null? tup1) tup2]
[(null? tup2) tup1]
[else (cons (add (car tup1)(car tup2))(tup+ (cdr tup1) (cdr tup2)))])))
(define t1 (list 10 20 30 50 60 70))
(define t2 (list 3 4 5 6))
(define t3 (list 100 200 300))
;tests
;(tup+ t1 t3)
;(tup+ t2 t3)
;(tup+ t2 t1)
(define grtr
(lambda (n m)
(cond
[(zero? n) #f]
[(zero? m) #t]
[else (grtr(sub1 n)(sub1 m))])))
;(grtr 4 6)
;(grtr 3 1)
;(grtr 1 1)

(define less
(lambda (n m)
(cond
[(zero? m) #f]
[(zero? n) #t]
[else (less(sub1 n)(sub1 m))])))
;(less 4 6)
;(less 3 1)
;(less 1 1)
(define eq?
(lambda (n m)
(cond
[(and(zero? n)(zero? m))]
[(or(zero? n)(zero? m)) #f]
[else (eq? (sub1 n)(sub1 m))])))
;(eq? 1 3)
;(eq? 3 1)
;(eq? 0 1)
;(eq? 1 1)
;(eq? 0 0)

(define div
(lambda (n m)
(cond
[(eq? m 0) "Err:div by 0"]
[(less n m) 0]
[(add1 (div (subt n m) m))])))
(div 45 9)
(div 45 5)
(div 45 1)
(div 45 0)
25 changes: 25 additions & 0 deletions SchemerStringOps.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#lang racket

(define atom?
(lambda (l)
(cond [(or (null? l)(pair? l)) #f]
[else #t])))


(define lat?
(lambda (l)
(cond
[(null? l) #t]
[(atom? (car l)) (lat? (cdr l))]
[else #f]
)))
(define multiSubst
(lambda (lat old new)
(cond
[(null? lat) (quote())]
[(eq?(car lat) old)
(cons new (multiSubst(cdr lat)))]
[else cons (car lat)
(multiSubst (cdr lat))]
)))

11 changes: 11 additions & 0 deletions guess.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname guess) (read-case-sensitive #t) (teachpacks ((lib "guess-gui.rkt" "teachpack" "htdp") (lib "guess.rkt" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "guess-gui.rkt" "teachpack" "htdp") (lib "guess.rkt" "teachpack" "htdp")) #f)))
(define(check-guess guess target)
(cond [(> guess target) 'too_large]
[(< guess target) 'too_small]
[else 'correct]
)
)

(guess-with-gui check-guess)
19 changes: 19 additions & 0 deletions quadratic.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname quadratic) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
(define(how-many a b c)
(cond[(= 0 a) "degenerate"]
[(>(* b b)(* 4 a c)) 2]
[(=(* b b)(* 4 a c)) 1]
[(<(* b b)(* 4 a c)) 0]
)
)
(define(how-many2 a b c)
(cond[(= 0 a) "degenerate"]
[(>(discriminant a b c)0) 2]
[(=(discriminant a b c)0) 1]
[(<(discriminant a b c)0) 0]
)
)
(define(discriminant a b c)
(-(* b b)(* 4 a c)))

0 comments on commit 58c0638

Please sign in to comment.