fork download
  1. #lang racket
  2.  
  3. (require "util/p-list.rkt")
  4.  
  5. (putprop! 'Harry '(Jane Bill) '#:children)
  6. (putprop! 'Jane '(Joe Diane) '#:children)
  7. (putprop! 'Bill '(Julia Mike) '#:children)
  8. (putprop! 'Julia '(Frank Suzan) '#:children)
  9. (putprop! 'Frank '(Anne) '#:children)
  10.  
  11. ;;; 展開関数
  12. (define (expand person)
  13. (keyword-get person '#:children '()))
  14.  
  15. (define (expand-path path)
  16. (let loop ((temp (expand (car path))) (result '()))
  17. (if (null? temp)
  18. result
  19. (loop (cdr temp) (cons (cons (car temp) path) result)))))
  20.  
  21. (define (related person1 person2)
  22. (let loop ((stack `((,person1))) (visited '()))
  23. (if (null? stack)
  24. null
  25. (let ((head (car stack)) (tail (cdr stack)))
  26. (let ((person (car head)))
  27. (if (eq? person person2)
  28. (reverse head)
  29. (loop (if (memq person visited)
  30. tail
  31. (append (expand-path head) tail))
  32. (cons person visited))))))))
Runtime error #stdin #stdout #stderr 0.55s 69064KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
open-input-file: cannot open module file
  module path: /home/GEK1Zw/util/p-list.rkt
  path: /home/GEK1Zw/util/p-list.rkt
  system error: no such file or directory; rktio_err=3
  context...:
   maybe-raise-missing-module
   default-load-handler
   standard-module-name-resolver
   perform-require!78
   for-loop
   finish
   [repeats 1 more time]
   pass-1-and-2-loop
   module-begin-k
   expand-module16
   expand-capturing-lifts
   expand-single
   temp74_0
   compile16
   temp68_2
   loop