Incidentally, a more concise way of doing this would be:

(define target (build-path "tarzan")) ; convert to path only once
(for/or ([item (in-directory "/tmp/test")]) ; or whatever directory you
want to start in
  (equal? target (file-name-from-path item)))

On Sat, May 8, 2021 at 3:50 AM Utkarsh Singh <[email protected]>
wrote:

> Hi,
>
> First of all I would like to thank Racket community for creating and
> maintaining top quality documentation at https://docs.racket-lang.org/
> and even providing a local copy for it.
>
> Currently I am having some difficulties in understanding this letrec
> example from Racket Guide docs
> (
> https://docs.racket-lang.org/guide/let.html#%28part._.Recursive_.Binding__letrec%29
> ):
>
> (letrec ([tarzan-near-top-of-tree?
>           (lambda (name path depth)
>             (or (equal? name "tarzan")
>                 (and (directory-exists? path)
>                      (tarzan-in-directory? path depth))))]
>          [tarzan-in-directory?
>           (lambda (dir depth)
>             (cond
>               [(zero? depth) #f]
>               [else
>                (ormap
>                 (λ (elem)
>                   (tarzan-near-top-of-tree? (path-element->string elem)
>                                             (build-path dir elem)
>                                             (- depth 1)))
>                 (directory-list dir))]))])
>   (tarzan-near-top-of-tree? "tmp"
>                             (find-system-path 'temp-dir)
>                             4))
>
> Problem:
> I having some problem on how recursion is working here and what is the
> problem we are solving here.  Are we finding a file with (name?
> "tarzan") or something else?
>
> --
> Utkarsh Singh
> http://utkarshsingh.xyz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87h7jdslzh.fsf%40gmail.com.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKodbqAe6DB1rBKBckDWST6f75OV4_35-dcceR7neNfHuaA%40mail.gmail.com.

Reply via email to