sva36853.scm 520 B

123456789101112131415161718192021
  1. (module-compile-options warn-as-error: #t)
  2. (define (my-member (key::String) (strings::java.util.List[java.lang.String]))
  3. (let ((iter (strings:iterator)))
  4. (let loop ()
  5. (if (iter:hasNext)
  6. (let ((next (iter:next)))
  7. (if (eq? (next:intern) key)
  8. #t
  9. (loop)))
  10. #f))))
  11. (define strlist ::java.util.List[java.lang.String]
  12. ["ab" "cd" "ef"])
  13. (format #t "~s~%" strlist)
  14. ;; Output: #("ab" "cd" "ef")
  15. (format #t "~s ~s~%"
  16. (my-member "cd" strlist)
  17. (my-member "gg" strlist))
  18. ;; Output: #t #f