Re: [racket-users] Re: HTDP2e part 4: 20.3 Refining Functions dir.rkt

2020-03-20 Thread Ben Greenman
On 3/20/20, Aron Zvi  wrote:
> Thanks for your reply Ben.
>
> I understand that I am supposed to be getting a Dir instance.
> My confusion is indeed regarding the value of the name field of Dir for
> which I get a (full) path symbol of the directory and not just the folder
> name as I would expect.
>
> When I run (create-dir "test") and the test folder is in the same folder as
>
> my racket racket file (using just the folder name as you suggested), I get
> the following Dir instance for which the symbol is still the path to the
> folder from the given root
>
> (make-dir
>  'test
>  (list
>   (make-dir
>*'test/a*
>(list (make-dir *'test/a/docs* '() '()))
>(list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "")
> (make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
>  (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))
>
> *I am expecting to get this *
>
> (make-dir
>  'test
>  (list
>   (make-dir
>*'a*
>(list (make-dir *'docs* '() '()))
>(list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "")
> (make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
>  (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))

Ok, I see how that makes Exercise 339 more difficult. Thanks for
pointing this out.

In Racket, I would use `symbol->string` and `file-name-from-path` to
get the name.

In ISL, I'd use `symbol->string` and `string->list` to get started,
then design a function that takes takes all the characters after the
last #\/ character in a list (or all characters if there is no #\/)

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R72khWOazwqVnmR2354%3DcbGxRkyn0u-xPTpemYpy1ES7Q%40mail.gmail.com.


[racket-users] Re: HTDP2e part 4: 20.3 Refining Functions dir.rkt

2020-03-19 Thread Aron Zvi
Thanks for your reply Ben.

I understand that I am supposed to be getting a Dir instance.
My confusion is indeed regarding the value of the name field of Dir for 
which I get a (full) path symbol of the directory and not just the folder 
name as I would expect.

When I run (create-dir "test") and the test folder is in the same folder as 
my racket racket file (using just the folder name as you suggested), I get 
the following Dir instance for which the symbol is still the path to the 
folder from the given root

(make-dir
 'test
 (list
  (make-dir
   *'test/a*
   (list (make-dir *'test/a/docs* '() '()))
   (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "") 
(make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
 (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))

*I am expecting to get this *

(make-dir
 'test
 (list
  (make-dir
   *'a*
   (list (make-dir *'docs* '() '()))
   (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 33) "") 
(make-file "me.txt" 0 (make-date 2020 3 20 13 1 42) ""
 (list (make-file ".DS_Store" 6148 (make-date 2020 3 20 13 7 28) "")))



On Thursday, 19 March 2020 17:01:59 UTC+7, Aron Zvi wrote:
>
> Hey guys,
>
> In part 4 section 20.3 Refining Functions I am using (require htdp/dir) 
> and (create-dir DIR-PATH). I get back a Dir instance with name value being 
> a full path symbol of the folder. ie. (make-dir 
> '/Users/SSS/Documents/xyz empty empty). 
> This does not seem to be in line with the exercises in the section where 
> it seems that I should be getting back just the folder name.
> I am missing something? 
>
>
>
>
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2ba65d76-e548-4fa0-831e-bfce2f9daca7%40googlegroups.com.