Re: [racket-users] How can I increase expansion+compilation speed?

2020-07-20 Thread Ryan Kramer
Thanks Ryan, the macro profiler is great! It quickly identified a macro 
that I was able to convert to a procedure. (I'm not sure why I made it a 
macro in the first place.) And the .zo file decreased from about 910KB to 
130KB, and the compilation speed went from 40 seconds to about 8 seconds 
(with debugging). I can probably do even better, but fixing this first big 
problem was quite a relief!

On Monday, July 20, 2020 at 8:42:57 AM UTC-5, Ryan Culpepper wrote:
>
> One thing to check is the size of the resulting bytecode file. When I 
> compiled it, I got a 911 KB .zo file. So the most likely reason is that 
> your macros are just producing a lot of code.
>
> You can run the macro profiler (eg, `raco macro-profiler aw-schema.rkt`) 
> to get a summary of what macros contribute most to the compiled code size. 
> See 
> https://docs.racket-lang.org/macro-debugger/index.html#(part._.Macro_.Profiler)
>  
> for more details. I also gave a talk about the macro profiler called "The 
> Cost of Sugar" a few years ago at RacketCon. The slides are at 
> http://www.ccs.neu.edu/home/ryanc/talks/racket18-sugar.pdf, and there 
> should be a recording online somewhere.
>
> The usual fix is to use helper functions. There are some examples in the 
> slides.
>
> Ryan
>

-- 
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/1b403370-3382-42a4-9ce1-8a168e3121cao%40googlegroups.com.


[racket-users] New week, new Racket! What are you folks up to?

2020-07-20 Thread Stephen De Gabrielle
I’ve been seeing some great entries in the Quickscript competition and I’m 
looking forward to the Standard-fish competition. 

What about you?
Answer here or discuss on 
 - https://racket.slack.com/ (Sign up at https://racket-slack.herokuapp.com/ )
 - `#racket` IRC on freenode.net https://botbot.me/freenode/racket/

If you are on Twitter - follow @racketlang

Don’t forget to sign up for, and contribute Racket News to Racket News at 
https://racket-news.com/ AND submit your links to Racket Stories 
https://racket-stories.com/

Kind regards

Stephen

-- 
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/5e2928ab-3281-47f8-955d-eb2a6b67a071o%40googlegroups.com.


Re: [racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread David Storrs
"double post", not "dinner post".  Damn. Email needs an edit function and
no autocorrect.

On Mon, Jul 20, 2020, 1:09 PM David Storrs  wrote:

> First off, if this was an intentional dinner post, well played. :>
>
>
> If you don't want to use built-in functions, I would look at using a hash
> to track what you've already seen and then cons things together depending
> on if they're in the hash.
>
> For the second, maybe recur through the list using a hash to track the
> most recent index of each item, then pop back up through the recursion
> consing things together based on whether you're at the specified index.
> That's my first thought, anyway.
>
>
> On Mon, Jul 20, 2020, 12:04 PM JJ C  wrote:
>
>> In Beginning Student with List Abbreviations
>>
>> I am struggling to come up with functions to remove duplicates from a
>> list while maintaining the order of the list.
>>
>> one function to remove duplicates from the left,
>>
>> i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5
>>
>> and one from the right.
>>
>> i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5
>>
>> What are the functions for removing duplicates from each left and right
>> side? If you need to, use helper functions and append, cond, cons, equal?,
>> etc but not using reverse or any built-in functions.
>>
>> --
>> 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/6049507b-094e-43c9-9dda-28237fcb57d8n%40googlegroups.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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoepLmKVqm1hJWun5eQDmCWTJYFzQB59tukgaOvufGOAzw%40mail.gmail.com.


Re: [racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread David Storrs
First off, if this was an intentional dinner post, well played. :>


If you don't want to use built-in functions, I would look at using a hash
to track what you've already seen and then cons things together depending
on if they're in the hash.

For the second, maybe recur through the list using a hash to track the most
recent index of each item, then pop back up through the recursion consing
things together based on whether you're at the specified index. That's my
first thought, anyway.


On Mon, Jul 20, 2020, 12:04 PM JJ C  wrote:

> In Beginning Student with List Abbreviations
>
> I am struggling to come up with functions to remove duplicates from a list
> while maintaining the order of the list.
>
> one function to remove duplicates from the left,
>
> i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5
>
> and one from the right.
>
> i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5
>
> What are the functions for removing duplicates from each left and right
> side? If you need to, use helper functions and append, cond, cons, equal?,
> etc but not using reverse or any built-in functions.
>
> --
> 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/6049507b-094e-43c9-9dda-28237fcb57d8n%40googlegroups.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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoe_9sPOesQHm6H-C1WPiGW5oNnd4LFxB-urSqSW9SRkmA%40mail.gmail.com.


[racket-users] Removing duplicates in a list in Dr. Racket

2020-07-20 Thread JJ C


In Beginning Student with List Abbreviations

I am struggling to come up with functions to remove duplicates from a list 
while maintaining the order of the list.

one function to remove duplicates from the left,

i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5

and one from the right.

i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5

What are the functions for removing duplicates from each left and right 
side? If you need to, use helper functions and append, cond, cons, equal?, 
etc but not using reverse or any built-in functions.


For example, with unique-left I came up with the below code but it only 
removes any consecutive duplicates 

e. g. (list 2 3 4 4 5 3) -> (list 2 3 4 5 3)


;(define (unique-left lst)

 ; (cond

  ; [(empty? lst) 0]

   ;[(empty? (rest lst)) lst]

   ;[else

;  (if (equal? (first lst) (first (rest lst)))

 ; (unique-left (rest lst))

  ;(cons (first lst) (unique-left (rest lst]))


So the code does not get me the unique-left like I want to show as the top 
example. 

-- 
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/4739e5ce-d328-4d09-859a-bacac2b1989fn%40googlegroups.com.


[racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread JJ C


In Beginning Student with List Abbreviations

I am struggling to come up with functions to remove duplicates from a list 
while maintaining the order of the list.

one function to remove duplicates from the left,

i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5

and one from the right.

i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5

What are the functions for removing duplicates from each left and right 
side? If you need to, use helper functions and append, cond, cons, equal?, 
etc but not using reverse or any built-in functions.

-- 
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/6049507b-094e-43c9-9dda-28237fcb57d8n%40googlegroups.com.


Re: [racket-users] emoji in source code

2020-07-20 Thread Matthew Flatt
The emoji problem on Mac OS has to do with the system-level drawing
function, CGContextShowGlyphsAtPoint, that used at the Cairo layer, at
least in the version of Cairo that we're using. That function doesn't
support emoji glyphs.

A newer version of Cairo handles emoji glyphs:

https://gitlab.freedesktop.org/cairo/cairo/commit/416a0005ab6a2b9a709d05281025e3581d612989?expanded=1

So, I've put "upgrade Cairo" on my todo list.


At Sun, 19 Jul 2020 16:36:53 -0500, Robby Findler wrote:
> I'm not sure what's going on, but this smily works: ☺
> 
> Robby
> 
> 
> On Sun, Jul 19, 2020 at 10:55 AM Shriram Krishnamurthi 
> wrote:
> 
> > I wrote the following program:
> >
> >   (define /: ')
> >
> > which at least on my screen looks like
> >
> >
> >
> > in Aquamacs and in my browser (modulo dark/light mode).
> >
> > However, no matter which mode I use in OS X AND which color mode I use in
> > DrRacket, the emoji just isn't visible:
> >
> >
> >
> > Not the most pressing problem in the world, but figured this is probably
> > not desirable.
> >
> > Shriram
> >
> > --
> > 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/af814198-b86b-4905-a741-4b59d605
> ca8co%40googlegroups.com
> > 
>  5ca8co%40googlegroups.com?utm_medium=email_source=footer>
> > .
> >
> 
> -- 
> 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/CAL3TdOMS5KWw0cj_jzzWpeO1icNZ1Ez
> %2BKkjZt%2B3PLiY96BwoaA%40mail.gmail.com.
> 
> 
> --
> [image/png "AutoGeneratedInlineImage1"] [~/Desktop & open] [~/Temp & open]
> .
> 
> 
> --
> [image/png "AutoGeneratedInlineImage2"] [~/Desktop & open] [~/Temp & open]
> .

-- 
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/20200720090250.1da%40sirmail.smtp.cs.utah.edu.


[racket-users] Re: How can I increase expansion+compilation speed?

2020-07-20 Thread Ryan Kramer
Thanks to both of you.

It does expand to a reasonably large amount of code, a small example is 
below. The processing that define-schema does shouldn't be worse than 
O(N*M) where N is the number of tables and M is the number of unique 
procedure names. Which is not linear, but also probably not large enough to 
be the main culprit. I added `(println stx-being-returned)` to 
define-schema and it gets printed relatively quickly. So probably the size 
of the generated code is the main culprit. I'll try Ryan C's tips as soon 
as I have time; they look promising.

(define-schema $$
  (table A
 #:property
 [foo (%%scalar "foo-given-A" this)])
  (table B
 #:property
 [foo (%%scalar "foo-given-B" this)]
 [bar (%%scalar "bar-given-B" this)]))

; Approximately expands to
#;(begin
(define A (make-table 'A))
(define B (make-table 'B))
(define (foo x)
  (cond
[((instanceof A) x)
 (%%scalar "foo-given-A" x)]
[((instanceof B) x)
 (%%scalar "foo-given-B" x)]
[else (error "expected instanceof A or B, got" x)]))
(define (bar x)
  (cond
[((instanceof B) x)
 (%%scalar "bar-given-B" x)]
[else (error "expected instanceof B, got" x)])))

-- 
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/9900daba-8dd8-4e46-88ef-84fdeb53f11fo%40googlegroups.com.


Re: [racket-users] How can I increase expansion+compilation speed?

2020-07-20 Thread Ryan Culpepper
One thing to check is the size of the resulting bytecode file. When I
compiled it, I got a 911 KB .zo file. So the most likely reason is that
your macros are just producing a lot of code.

You can run the macro profiler (eg, `raco macro-profiler aw-schema.rkt`) to
get a summary of what macros contribute most to the compiled code size. See
https://docs.racket-lang.org/macro-debugger/index.html#(part._.Macro_.Profiler)
for more details. I also gave a talk about the macro profiler called "The
Cost of Sugar" a few years ago at RacketCon. The slides are at
http://www.ccs.neu.edu/home/ryanc/talks/racket18-sugar.pdf, and there
should be a recording online somewhere.

The usual fix is to use helper functions. There are some examples in the
slides.

Ryan


On Mon, Jul 20, 2020 at 2:08 AM Ryan Kramer 
wrote:

> Using DrRacket, the following file takes 18 seconds to compile without
> debugging, or about 40 seconds to compile with debugging:
> https://raw.githubusercontent.com/default-kramer/plisqin-tutorials/e844825b48137553246c64e73516d880b9068825/define-schema-answer-key/aw-schema.rkt
>
> When I say "compile", I mean that I click "Run" in DrRacket and wait for
> it to give me REPL access. But that file just defines and provides a slew
> of functions, it doesn't really do anything at runtime.
>
> (Using the command-line `racket that-file.rkt` takes only 7 seconds, which
> is OK. But many people, myself included, primarily use DrRacket.)
>
> Admittedly, this is 612 dense lines of code. So it might just be a case of
> "yeah, that's about how long it takes." But it's also possible (or
> probable?) that I have some inefficient macros somewhere. Are there any
> tools/techniques I can use to help me reduce the compilation time?
>
> --
> 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/40e40eff-a0be-4850-9360-c9648cb5b8d9o%40googlegroups.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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33q%3D1d1ojXVrcsM1mYCa2%2BcLkN2-x7x0WM197BukAA%3DRuzA%40mail.gmail.com.


Re: [racket-users] How can I increase expansion+compilation speed?

2020-07-20 Thread Linus Björnstam
40s to compile seems rather excessive, considering macros like match that also 
do a lot of work are instant, almost regardless of their size (I once managed 
to generate a 2000 line (match ...) and hardly noticed). Is there anything in 
define-schema that makes it non-linear? Do you process tables or columns over 
and over? How much code does it expand to?

I might have some computer time tonight, and will be able to test it out and 
explore the library you are using.

-- 
  Linus Björnstam

On Mon, 20 Jul 2020, at 02:08, Ryan Kramer wrote:
> Using DrRacket, the following file takes 18 seconds to compile without 
> debugging, or about 40 seconds to compile with debugging: 
> https://raw.githubusercontent.com/default-kramer/plisqin-tutorials/e844825b48137553246c64e73516d880b9068825/define-schema-answer-key/aw-schema.rkt
> 
> When I say "compile", I mean that I click "Run" in DrRacket and wait 
> for it to give me REPL access. But that file just defines and provides 
> a slew of functions, it doesn't really do anything at runtime.
> 
> (Using the command-line `racket that-file.rkt` takes only 7 seconds, 
> which is OK. But many people, myself included, primarily use DrRacket.)
> 
> Admittedly, this is 612 dense lines of code. So it might just be a case 
> of "yeah, that's about how long it takes." But it's also possible (or 
> probable?) that I have some inefficient macros somewhere. Are there any 
> tools/techniques I can use to help me reduce the compilation time?
> 
>  -- 
>  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/40e40eff-a0be-4850-9360-c9648cb5b8d9o%40googlegroups.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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/12a6b283-5e70-4bbf-b377-24905c38ee29%40www.fastmail.com.