Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 1.12 KB | None | 0 0
  1. (define-struct fileinfo (name format size path))
  2. ;; A FileInfo is a (make-fileinfo Str Sym Num Str)
  3. ;; requires:
  4. ;;          name is a non-empty string
  5. ;;             that contains only alphanumeric characters
  6. ;;          format is one of 'doc, 'txt, 'rtf, 'zip,
  7. ;;             'raw, 'jpg, 'wav, 'mp3
  8. ;;          size > 0, and represents the size of the file in kilobytes
  9. ;;          path is a non-empty string that
  10. ;;             starts with a / character and ends with an alphanumeric character
  11. ;;             contains only / and alphanumeric characters
  12. ;;             with at least one alphanumeric character
  13. ;;             that appears between any two / characters
  14. ;;             (representing the name of a folder)
  15.  
  16. ;; A Directory is a (listof FileInfo)
  17. ;; requires:
  18. ;;    the elements of the list represent information about
  19. ;;        files contained in the Directory
  20. ;;    all elements of the list have the same path
  21. ;;    each element of the list is uniquely identified by
  22. ;;        its name and format (i.e. its full name)
  23.  
  24. (define (dir-size direct)
  25.   (cond
  26.     [(empty? direct) 0]
  27.     [(+ (fileinfo-name])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement