-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
362ea3d
commit f9f71e5
Showing
12 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#lang racket/base | ||
|
||
(require "mk.rkt") | ||
(require "08-mk-compiled.rkt") | ||
|
||
(defrel (appendo l1 l2 l3) | ||
(conde | ||
|
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#lang racket | ||
|
||
(require hosted-minikanren) | ||
|
||
(defrel (route origin end path) | ||
(conde | ||
[(== origin end) (== path '())] | ||
[(fresh (hop remainder) | ||
(== path (cons (list origin hop) remainder)) | ||
(absento origin remainder) | ||
(direct origin hop) | ||
(route hop end remainder))])) | ||
|
||
(defrel (direct a b) | ||
(conde | ||
[(== a "BOS") (== b "SEA")] | ||
[(== a "HOU") (== b "SLC")] | ||
[(== a "SEA") (== b "DEN")] | ||
[(== a "SEA") (== b "BOS")] | ||
[(== a "DEN") (== b "HOU")] | ||
[(== a "SLC") (== b "SFO")])) | ||
|
||
(run* (q) (route "SEA" "HOU" q)) |
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#lang racket/base | ||
|
||
(require hosted-minikanren | ||
hosted-minikanren/inspect) | ||
|
||
(defrel (r1 a b) | ||
(fresh (x y) | ||
(== a (list 1 x)) | ||
(== b (list 1 y)) | ||
(== x y))) | ||
|
||
#;(print-relation-code/after-occurs-check r1) | ||
|
||
|
||
|
||
|
||
|
||
#;(defrel (r2 x y) | ||
(fresh (a b) | ||
(== x (cons '5 '6)) | ||
(goal-from-expression | ||
(void #| unknown racket code |#)) | ||
(== a b) | ||
(== y x))) | ||
|
||
#;(print-relation-code/after-occurs-check r2) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#lang racket | ||
|
||
(provide download-flights-csv create-flights-table query-flight-rows) | ||
|
||
(require hosted-minikanren | ||
hosted-minikanren/demos/icfp2024/facts | ||
csv-reading | ||
racket/list | ||
net/url | ||
net/url-string | ||
db sql) | ||
|
||
(define SOURCE | ||
"https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat") | ||
|
||
;; () -> [Listof [Listof String String]] | ||
;; Should produce a list of flights, each flight a list matching the data schema | ||
(define (download-flights-csv) | ||
(for/list ([row (csv->list (get-pure-port (string->url SOURCE)))]) | ||
(list (third row) (fifth row)))) | ||
|
||
(define (create-flights-table v) | ||
(void)) | ||
|
||
(define-facts-table flights [flightfrom flightto] | ||
#:initial-data (download-flights-csv)) | ||
|
||
(defrel (direct a b) | ||
(query-facts flights a b)) | ||
|
||
(define (query-flight-rows conn a-arg b-arg) | ||
(run* (a b) | ||
(== a a-arg) | ||
(== b b-arg) | ||
(direct a b))) |