(define l1 (list "See" "ee " "e S" " Sp" "Spo" "pot" "ot " "t r" " ru" "run" "un.")) (define al1 '((" ca" 1) (" ha" 1) (" in" 1) (" th" 1) ("The" 1) ("at " 1) ("at." 1) ("cat" 1) ("e c" 1) ("e h" 1) ("hat" 1) ("he " 2) ("in " 1) ("n t" 1) ("t i" 1) ("the" 1)) ((" th" 34) ("the" 20) ("at " 18) ("hat" 15) ("ed " 13) ("her" 13) ("tha" 13) (" de" 12) ("he " 11) ("re " 11))) ;; DATA DEFINITION ;; A path-string is one of: ;; - A path ;; - A string ;; directory-names : path-string -> (listof string) ;; list the names in the given directory, in alphabetical order ;; build-path : path-string path-string -> path ;; create a path by combining parts using the native notation ;; comp50-path : path-string -> string ;; return the full path of a file relative to a comp50 collection ;; basename : path-string -> string ;; returns the last name in a given path ;; DATA DEFINITION ;; A `1string` is a string of length exactly 1 ;; read-1bytes : path-string -> (listof 1string) ;; return the contents of a given file, interpreted as bytes ;; geturl-1bytes : string -> (listof 1string) ;; produce the list of bytes served by the given URL, which must be good ;; DATA DEFINITION ;; An sx is one of: ;; - A string ;; - A number ;; - A symbol ;; - A (listof sx) ;; write-file-sexp : string sx -> string ;; write the given S-expression to the given named file, returning the file's name ;; read-file-sexp : string -> sx ;; read the given S-expression from the file of the given pathname #| > (directory-names (comp50-path "language-test")) (list "abcxyz") > (directory-names (comp50-path "tiny-language-training")) (list "English" "French" "German" "Polish") > (directory-names (comp50-path "language-training")) (list "Czech" "English" "French" "German" "Hungarian" "Italian" "Polish" "Spanish") > (read-1bytes (comp50-path (build-path "language-test" "abcxyz"))) (list "a" "b" "c" "x" "y" "z") > (geturl-1bytes "http://www.cs.tufts.edu/comp/50/nothing.txt") (list "N" "o" "t" "h" "i" "n" "g" "'" "s" " " "h" "e" "r" "e" "." "\n") > (basename "/home/nr/.profile") ".profile" > (basename "/comp/50/www/homework") "homework" > (write-file-sexp "/tmp/test.rktd" '(An S-exp ("string" 7 9))) "/tmp/test.rktd" > (read-file-sexp "/tmp/test.rktd") (list 'An 'S-exp (list "string" 7 9)) > (write-file-sexp "/tmp/image.rktd" (circle 5 "solid" "black")) write-file-sexp: expects a S-expression as second argument, given # > |# (define log-10/10 (/ (log 10) 10)) ;; log-decibans : number -> number ;; return the 10 times the base-10 logarithm of the given number (define (log-decibans x) (/ (log x) log-10/10)) (check-within (log-decibans 1) 0 EPSILON) (check-within (log-decibans 10) 10 EPSILON) (check-within (log-decibans 100) 20 EPSILON) (check-within (log-decibans 1/10) -10 EPSILON) (define sample '(("English" #i-124879.38840876492) ("German" #i-136502.98974519692) ("French" #i-138755.4804011435) ("Spanish" #i-140403.25530245638) ("Italian" #i-140643.53502622052) ("Hungarian" #i-141477.80928918015) ("Czech" #i-142751.49331737417) ("Polish" #i-143355.53183452427) ("Unknown" #i-156920.91613972152)) ) (define sample2 '(("English" #i0.36898273367830303) ("German" #i0.25326695630096535) ("French" #i0.24965274414918953) ("Italian" #i0.24356957546717814) ("Spanish" #i0.24140594907631213) ("Polish" #i0.2054360930761648) ("Czech" #i0.19650868079989064) ("Hungarian" #i0.19644545018071768) ("Unknown" #i0.007751224544134543)) ) (define sample3 '(("English" #i-258080.31739165334) ("French" #i-259023.08641358386) ("Spanish" #i-270013.69208337733) ("German" #i-271836.10062956245) ("Italian" #i-273627.51560851745) ("Hungarian" #i-281419.25852654263) ("Czech" #i-281716.0129245808) ("Polish" #i-284114.33976111293) ("Unknown" #i-307050.5955772443)) )