Skip to content

Commit

Permalink
ackerman and halting problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Williamson committed Mar 18, 2019
1 parent 58ccb54 commit 86e8398
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ackerman.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#lang racket
(define A
(lambda ( n m)
(cond
((zero? n) ( add1 m))
((zero? m) (A (sub1 n) 1))
(else (A (sub1 n)
(A n (sub1 m)))))))
13 changes: 13 additions & 0 deletions ackerman.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#lang racket
(define A
(lambda (n m)
(cond
((zero? n) (add1 m))
((zero? m) (A (sub1 n) 1))
(else (A (sub1 n)
(A n (sub1 m)))))))

(A 2 1) ;5
(A 3 2) ;29

;(A 4 3) ;Keeps going; presumabley stops
9 changes: 9 additions & 0 deletions exactfilter.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#lang racket
(define exact-filters '(('type1 (cons '1 '2))
('type2 (cons '100 111)
('type1 (cons '3 '4))
)))

(define result (car (group-by (λ (type) (eq? type type)) exact-filters)))

result
22 changes: 22 additions & 0 deletions little-schemer-halting-problem.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#lang racket

(define pick
(lambda (pos lat)
(cond
((eq? pos 1)(car lat))
(else (pick (sub1 pos)(cdr lat))))))

(pick 1 '(a b c))
(pick 2 '(a b c))

(define looking
(lambda (a choice lat)
(keep-looking a (pick choice lat) lat)))

(define keep-looking
(lambda (a pos lat)
(cond
((eq? (pick pos lat) a) #t)
(else (looking a pos lat)))))

(looking 'caviar 1 '(6 2 3 caviar 5 7 3))
3 changes: 2 additions & 1 deletion little-schemer-halting-problem.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
((eq? (pick pos lat) a) #t)
(else (looking a pos lat)))))

(looking 'caviar 1 '(6 2 4 caviar 5 7 3))
(looking 'caviar 1 '(6 2 4 caviar 5 7 3))
;(looking 'caviar 1 '(7 1 2 caviar 5 6 3))

0 comments on commit 86e8398

Please sign in to comment.