The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled HTML Code
Posted by: bh | February 3, 2008 @ 4:57pm
HTML Code
[
Download
]
;;memberp : Any conspair -> boolean ;;determines if the element is in the conspair ;;this will be used for relations (defun memberp (e l) (cond ((or (= (car l) e) (= (cdr l) e)) T) (t nil))) ;;set0-helper : String string-relationp -> setp ;;returns a set of the elements in the relation related to the input String (defun set0-helper (e r) (cond ((endp r) nil) ((memberp e (car r)) (cons (car(car r)) (cons (cdr(car r)) (set0-helper e (cdr r))))) (t (set0-helper e (cdr r))))) ;;list-append : list list -> list ;;appends the second list onto the first (defun list-append (list1 list2) (cond ((endp list1) list2) (t (cons (car list1) (list-append (cdr list1) list2))))) (assert-event(=(list-append '(1 2 3) '(4 5 6)) '(1 2 3 4 5 6))) ;;set0 : string-relationp setp -> setp ;;returns a set of the elements related to the elements of the original set (defun set0 (r s) (cond ((endp s) nil) (t (list-append (set0-helper (car s) r) (set0 (cdr s) r))))) (assert-event (=(set0 (list (cons "Alice" "Mike") (cons "Mike" "Julia") (cons "Julia" "Kenny") (cons "Alice" "Kenny")) (list "Alice" "Julia")) (list "Alice" "Mike" "Alice" "Kenny" "Mike" "Julia" "Julia" "Kenny"))) (assert-event (=(set0 (list (cons "Joe" "John") (cons "Pete" "Joe") (cons "Luke" "Alice") (cons "Ashley" "Mike") (cons "Ashley" "Joe") (cons "Ryan" "Sarah") (cons "Mike" "Sarah")) (list "Mike" "Joe")) (list "Ashley" "Mike" "Mike" "Sarah" "Pete" "Joe" "Ashley" "Joe"))) ;;relation-trans : string-relationp setp -> setp ;;returns the set of users that they can meet via a sequence of introductions (defun relation-trans (r s) (cond ((= s (set0 r s)) s) (t (relation-trans r (set0 r s)))))
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.56 / 8
141 Votes
http://codebin.yi.org/101
page generated in 0.00 seconds