Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Christopher Lemmer Webber
Thanks everyone. I guess I misread the docs. Great to hear re: caching. Guess I wasn't screwing things up as I momentarily feared. :) Sam Tobin-Hochstadt writes: > Here are some quick numbers on the traditional Racket VM: > > ``` >> (define v (build-list 1000 values)) >> (time (list? v)) >

Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Sam Tobin-Hochstadt
Here are some quick numbers on the traditional Racket VM: ``` > (define v (build-list 1000 values)) > (time (list? v)) cpu time: 47 real time: 47 gc time: 0 #t > (time (list? v)) cpu time: 31 real time: 31 gc time: 0 #t > (time (list? v)) cpu time: 13 real time: 13 gc time: 0 #t > (time (list?

Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Shu-Hung You
>From the expansion result, match does check whether the inspected value is a list using list?. But at least for the current version of Racket (and the C VM), list? is handled specially and ``effectively takes constant time due to internal caching.'' (quoted from: https://docs.racket-lang.org/refer

Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Alexis King
> On Oct 29, 2019, at 12:41, Christopher Lemmer Webber > wrote: > > But the documentation says that the `list?` predicate is O(n). I’m not sure where you’re seeing that, but the documentation actually says just the opposite. Specifically, it says this: > This procedure effectively takes const

[racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Christopher Lemmer Webber
Imagine the following code: (let lp ([items '(1 2 3 4 5)]) (match items [(list head rest ...) (cons (* head 2) (lp rest))])) My gut feeling is "oh, this is just O(n) because it's pulling the top off the list quite efficient." But then I realized that: (match '(1 2 3 4

Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-29 Thread Thomas Dickerson
Hi All, Thanks for the information + various ideas. The various suggest constructs provide a helpful view on different corners of the language, but all appear to have the characteristic of throwing out the existing hashtable structure from the map and then reconstructing it from scratch for the ne

Re: [racket-users] expanding to typed/racket using #lang turnstile

2019-10-29 Thread William J. Bowman
This might be too minimal of an example. It looks like typed Racket doesn't want you to use Typed Racket types in certain contexts. To implement the functionality I think you want from that example, I would write the following #lang turnstile (require (only-in (prefix-in tr: typed/racket)

[racket-users] expanding to typed/racket using #lang turnstile

2019-10-29 Thread Raoul Schorer
Hi, I am attempting to expand to typed/racket from a custom language through #lang turnstile. Unfortunately, the macro stepper isn't helping me much as to how I should do that. So far, this minimal example: #lang turnstile (require (only-in (prefix-in tr: typed/racket) tr:#%m

Re: [racket-users] Help me understand FFI callouts in this context?

2019-10-29 Thread Matthew Flatt
I haven't been able to get Vulkan going on my machines, so I can't run your code enough to offer reliable advice. Still, I wonder whether making the callback atomic has any effect. To make the callback atomic: * Change the definition of `_PFN_vkDebugReportCallbackEXT` to add `#:atomic? #t` aft