Re: [racket-users] Racket Guide, REs, section 9.5

2018-11-09 Thread Jussi Salmela
Thanks for answering. I was at my wits’ end trying to think how the behavior of 
those two would differ and even tried a couple of experiments, to no avail 
unfortunately.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Racket Guide, REs, section 9.5

2018-11-06 Thread Jussi Salmela
At the end of section 9.5 there is the sentence:

   The non-greedy quantifiers are respectively: *?, +?, ??, {m}?, {m,n}?. 

I don't understand what {m}? is supposed to match because {m} means 'match 
exactly the previous pattern'.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Confused by the behavior of hash->list

2018-08-17 Thread Jussi Salmela
Cool, thanks!

On Fri, Aug 17, 2018 at 7:26 PM Paulo Matos  wrote:

>
>
> On 17/08/18 18:18, Jussi Salmela wrote:
> > Hi all!
> >
> > (I'm on 7.0)
> > Just to jump right to the point here are the hash example lines from the
> User Guide and a few added lines with comments that should make it clear
> what I am confused about:
> >
> > (define ht (make-hash))
> > (hash-set! ht "apple" '(red round))
> > (hash-set! ht "banana" '(yellow long))
> > (writeln ht)
> > (writeln (list? (hash-ref ht "apple")))
> > ;; This is how I assumed hash->list to behave:
> > (writeln (for/list ([key (hash-keys ht)])
> >(list key (hash-ref ht key
> > ;; This is how it behaves:
> > (writeln (hash->list ht))
> >
> >
> > This is the output I get:
> >
> > #hash(("banana" . (yellow long)) ("apple" . (red round)))
> > #t
> > (("apple" (red round)) ("banana" (yellow long)))
> > (("banana" yellow long) ("apple" red round))
> >
> > So I'm confused why the list is "flattened" by hash->list. I can manage
> the situation using for/list, I'm just wondering.
> >
>
> Hi,
>
> The list is not flattened, it's just not showing as much detail as you
> would probably like.
>
> From the docs of hash->list the result type is (listof (cons/c any/c
> any/c))
>
> This is an association list, so the result is:
> (("banana" . (yellow long)) ("apple" . (red round)))
>
> except that racket shows them as lists, and it looks like:
> (("banana" yellow long) ("apple" red round))
>
> This is the counterpart of hash constructors which get an assoc list as
> argument.
>
> > Thanks,
> > Jussi
> >
>
> Kind regards,
>
> --
> Paulo Matos
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.