We are finding a file (or directory) with name "tarzan" inside all 
directories inside given path upto given depth.
Recursion is needed here, because  tarzan-near-top-of-tree? calls  
tarzan-in-directory? and  tarzan-in-directory? calls  
tarzan-near-top-of-tree? for each file in given directory.

суббота, 8 мая 2021 г. в 12:50:09 UTC+5, Utkarsh Singh: 

> 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/a3d31da0-c9b7-4aac-a541-15137197d941n%40googlegroups.com.

Reply via email to