Re: [racket-users] Racket 6.4 very slow

2016-03-02 Thread Neil Van Dyke

Alex Harsanyi wrote on 03/02/2016 11:19 PM:
If it cannot be improved, perhaps a warning message should be printed 
in the eval window...


I like this idea.  Maybe add to the DrRacket REPL banner, the 
debugging/instrumentation options that are enabled.



Welcome to DrRacket, version 6.4 [3m].
Language: racket; memory limit: 128 MB.
>


Neil V.

--
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] Racket 6.4 very slow

2016-03-02 Thread Matthew Flatt
I see that there's a big difference in the effect of debugging mode for
this example in v6.3-v6.4 compared to earlier versions.

On my machine:

   Racket   DrRacket
 with debugging
 v6.2 ~2500 ms  ~3800 ms
 v6.4 ~2500 ms ~63000 ms

In both versions, debugging instrumentation is applied at the
granularity of terms that have source locations. The idea was that
having a source location is a good indication that the code is
something the user wrote, and not in a library.

Starting with v6.3, however, compiled bytecode preserves source
locations for syntax literals --- so, code in a macro implementation
has a source location when it appears in an expansion. With v6.3 and
later, debugging instrumentation is added at many more program points
in the expansion of the `for` macro.

Instead of using the existence of a source location to determine where
to add instrumentation, debugging should be based on the details of the
source location. I'm not immediately sure of the right rule, but I'll
work on it.

Another direction is to improve the overhead of the debugging
instumentation, even when it is applied at a fine granularity. I'm not
clear on why it's so expensive in this case, and I think it should be
easy to improve (but I might be wrong about that).


At Wed, 2 Mar 2016 22:06:54 -0500, Matthias Felleisen wrote:
> 
> 1. Don’t ever measure anything in drracket (version 6.4.1 or earlier). 
> 
> 2. Are you comparing two different installations of Racket like the OP does? 
> Or are you just saying something is slow sometimes? 
> 
> 
> 
> 
> > On Mar 2, 2016, at 8:21 PM, Alex Harsanyi  wrote:
> > 
> > I have the same problem with Racket 6.4 64Bit Windows (running on Windows 
> > 7):
> > 
> >> (time (total 10))
> >  cpu time: 85520 real time: 88070 gc time: 204
> > 
> > BTW, my "Choose Language" dialog box (Ctrl+L) has the following selected:
> > 
> >  * Debugging
> >  * Populate "compiled directories"
> >  * Preserve stack trace
> >  * Enforce constant definitions
> > 
> > When disabling the "Debugging", the time goes down significantly:
> > 
> >> (time (total 10))
> >  cpu time: 4555 real time: 5036 gc time: 63
> > 
> > If I also disable the "Preserve stack trace option", the time goes down a 
> bit more:
> > 
> >> (time (total 10))
> >  cpu time: 3619 real time: 3662 gc time: 31
> > 
> > I did not expect the debugging option to have such a huge impact.  I don't 
> even know what it does, as there is a separate "Debug" button in the toolbar, 
> which seems to work even when the option is disabled.
> > 
> > BTW, I ran raco setup as suggested in a previous message and after that, 
> DrRacket would not start up anymore [1] and I had to do a fresh install. 
> Racket was installed from the default installer package from racket-lang.org. 
> No additional packages added and the installation was not modified in any 
> way. 
> > 
> > Best Regards,
> > Alex.
> > 
> > [1] 
> https://drive.google.com/file/d/0B5h4XOdkim72bm04eDBGNWpFZ0E/view?usp=sharing
> > 
> > -- 
> > 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.
> 
> -- 
> 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.

-- 
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] Racket 6.4 very slow

2016-03-02 Thread Alex Harsanyi
On Thursday, March 3, 2016 at 11:06:56 AM UTC+8, Matthias Felleisen wrote:

> 1. Don’t ever measure anything in drracket (version 6.4.1 or earlier). 

Perhaps this explains why you could not reproduce the problem :-)

DrRacket is the tool most people use to write Racket programs, and I suspect a 
lot of the time the only place where they run their programs.  Most people will 
judge the speed of Racket by how fast programs run inside DrRacket.

Also, the OP was not talking about shaving a few milliseconds, or even a 2x 
slowdown, the time difference is huge (20x).  This slowdown is not expected by 
anyone who has some familiarity with other programming environments.  If it 
cannot be improved, perhaps a warning message should be printed in the eval 
window...

> 2. Are you comparing two different installations of Racket like the OP does? 
> Or are you just saying something is slow sometimes? 

My timings are from the same racket installation, Racket 6.4 64 bit Windows 7, 
default install.  Just to recap, for the same code example as the OP presented, 
running in DrRacket:

  * "Debug" and "Preserve stack trace" enabled -> 85 seconds
  * "Debug" disabled, "Preserve stack trace" enabled -> 4.5 seconds
  * "Debug" and "Preserve stack trace" disabled -> 3.6 seconds.

> 
> > On Mar 2, 2016, at 8:21 PM, Alex Harsanyi  wrote:
> > 
> > I have the same problem with Racket 6.4 64Bit Windows (running on Windows 
> > 7):
> > 
> >> (time (total 10))
> >  cpu time: 85520 real time: 88070 gc time: 204
> > 
> > BTW, my "Choose Language" dialog box (Ctrl+L) has the following selected:
> > 
> >  * Debugging
> >  * Populate "compiled directories"
> >  * Preserve stack trace
> >  * Enforce constant definitions
> > 
> > When disabling the "Debugging", the time goes down significantly:
> > 
> >> (time (total 10))
> >  cpu time: 4555 real time: 5036 gc time: 63
> > 
> > If I also disable the "Preserve stack trace option", the time goes down a 
> > bit more:
> > 
> >> (time (total 10))
> >  cpu time: 3619 real time: 3662 gc time: 31
> > 
> > I did not expect the debugging option to have such a huge impact.  I don't 
> > even know what it does, as there is a separate "Debug" button in the 
> > toolbar, which seems to work even when the option is disabled.
> > 
> > BTW, I ran raco setup as suggested in a previous message and after that, 
> > DrRacket would not start up anymore [1] and I had to do a fresh install. 
> > Racket was installed from the default installer package from 
> > racket-lang.org. No additional packages added and the installation was not 
> > modified in any way. 
> > 
> > Best Regards,
> > Alex.
> > 
> > [1] 
> > https://drive.google.com/file/d/0B5h4XOdkim72bm04eDBGNWpFZ0E/view?usp=sharing
> > 
> > -- 
> > 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.

-- 
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] unit "mixins"

2016-03-02 Thread David Van Horn
Hello,

I'm trying to do something like a unit "mixin", but have gotten stuck.

Here's a sketch of what I'd like:

#lang racket

(define-signature x^ (a))
(define-signature y^ (b))
(define-signature z^ (c))

(define-signature f^ (f))

(define-unit u@
  (import x^ y^ z^)
  (export f^)
  (define (f q) (+ a b c q)))

;; a transformer on units implementing f^
(define-unit double@
  (import (rename f^ (g f)))
  (export f^)
  (define (f x) (g (g x

(define-unit xyz@
  (import)
  (export x^ y^ z^)
  (define-values (a b c) (values 1 2 3)))

(define-values/invoke-unit/infer
  (link xyz@ u@))

I'd like to be able to do something in that last definition that is
essentially double@ "applied to" u@.  Is there some way to accomplish
that?  In particular, some way that doesn't require enumerating the
imports of u@?

Thanks,
David

-- 
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] Racket 6.4 very slow

2016-03-02 Thread Matthias Felleisen

1. Don’t ever measure anything in drracket (version 6.4.1 or earlier). 

2. Are you comparing two different installations of Racket like the OP does? Or 
are you just saying something is slow sometimes? 




> On Mar 2, 2016, at 8:21 PM, Alex Harsanyi  wrote:
> 
> I have the same problem with Racket 6.4 64Bit Windows (running on Windows 7):
> 
>> (time (total 10))
>  cpu time: 85520 real time: 88070 gc time: 204
> 
> BTW, my "Choose Language" dialog box (Ctrl+L) has the following selected:
> 
>  * Debugging
>  * Populate "compiled directories"
>  * Preserve stack trace
>  * Enforce constant definitions
> 
> When disabling the "Debugging", the time goes down significantly:
> 
>> (time (total 10))
>  cpu time: 4555 real time: 5036 gc time: 63
> 
> If I also disable the "Preserve stack trace option", the time goes down a bit 
> more:
> 
>> (time (total 10))
>  cpu time: 3619 real time: 3662 gc time: 31
> 
> I did not expect the debugging option to have such a huge impact.  I don't 
> even know what it does, as there is a separate "Debug" button in the toolbar, 
> which seems to work even when the option is disabled.
> 
> BTW, I ran raco setup as suggested in a previous message and after that, 
> DrRacket would not start up anymore [1] and I had to do a fresh install. 
> Racket was installed from the default installer package from racket-lang.org. 
> No additional packages added and the installation was not modified in any 
> way. 
> 
> Best Regards,
> Alex.
> 
> [1] 
> https://drive.google.com/file/d/0B5h4XOdkim72bm04eDBGNWpFZ0E/view?usp=sharing
> 
> -- 
> 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.

-- 
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] [ANN] trivial 0.1

2016-03-02 Thread Matthias Felleisen

> On Mar 2, 2016, at 6:14 PM, Benjamin Greenman  
> wrote:
> 
> In exchange I promise a beer or other legal refreshment at the next 
> Racket-Con :)


(Don’t promise 17-year olds what you can’t keep! )

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Alex Harsanyi
I have the same problem with Racket 6.4 64Bit Windows (running on Windows 7):

  > (time (total 10))
  cpu time: 85520 real time: 88070 gc time: 204

BTW, my "Choose Language" dialog box (Ctrl+L) has the following selected:

  * Debugging
  * Populate "compiled directories"
  * Preserve stack trace
  * Enforce constant definitions

When disabling the "Debugging", the time goes down significantly:

  > (time (total 10))
  cpu time: 4555 real time: 5036 gc time: 63

If I also disable the "Preserve stack trace option", the time goes down a bit 
more:

  > (time (total 10))
  cpu time: 3619 real time: 3662 gc time: 31

I did not expect the debugging option to have such a huge impact.  I don't even 
know what it does, as there is a separate "Debug" button in the toolbar, which 
seems to work even when the option is disabled.

BTW, I ran raco setup as suggested in a previous message and after that, 
DrRacket would not start up anymore [1] and I had to do a fresh install. Racket 
was installed from the default installer package from racket-lang.org. No 
additional packages added and the installation was not modified in any way. 

Best Regards,
Alex.

[1] 
https://drive.google.com/file/d/0B5h4XOdkim72bm04eDBGNWpFZ0E/view?usp=sharing

-- 
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] [ANN] trivial 0.1

2016-03-02 Thread Benjamin Greenman
Hello Racket Users,

I'm currently extending this library and writing a little essay on its
implementation. The essay would be much improved if I could report on
users-other-than-myself experience.

If you've used trivial and have any numbers or stories about convenience,
reduced LOC, or bugs found, I'd love to hear them!
In exchange I promise a beer or other legal refreshment at the next
Racket-Con :)

Ben


On Tue, Dec 15, 2015 at 10:33 AM, Benjamin Greenman <
benjaminlgreen...@gmail.com> wrote:

> Short answer: I made a package because I wanted to release as soon as
> possible & encourage feedback / new ideas.
>
>
> Longer answer: I don't think there's any reason TR couldn't integrate
> these "smarter" operators (specifically, macros that inspect their
> arguments before calling a core TR function). That's part of why I used the
> colon notation. But they should be opt-in rather than default features
> because the extra analysis fails in potentially-confusing ways.
>
> (let ([n 2]) (ann (-: n n) Zero)) ;; Type error
>
> These operators can also introduce type errors.
>
> (regexp-match #rx"hello" #"world")
>
> ;; Type error, generated by inferring the result type String from the
> regexp pattern
>
> That example is a bug in my implementation, but it shows how easily things
> can go strange. It's also possible that a user type error triggers a series
> of type errors in the expanded code.
>
>
>
> On Tue, Dec 15, 2015 at 9:27 AM, Matthias Felleisen 
> wrote:
>
>>
>> On Dec 15, 2015, at 2:14 AM, Alexis King  wrote:
>>
>> > This is pretty neat. Without looking too much into the documentation or
>> implementation, could you briefly elaborate on why these changes are in a
>> separate package rather than improvements to TR itself?
>>
>>
>> +1
>>
>>
>> >
>> > At a quick glance, you mention doing some sort of static analysis on
>> arguments in the normal macro expansion phase: is there any practical
>> reason why TR couldn’t export these? Are there any hidden incompatibilities
>> with the core Racket forms? Or is this just a philosophical division,
>> deciding that TR shouldn’t unnecessarily re-implement forms to perform
>> “magic” typechecking?
>> >
>> > Anyway, my curiosity aside, this is a cool idea. I’ll definitely
>> consider playing with this a bit if I can get some free time.
>> >
>> > Alexis
>> >
>> >> On Dec 14, 2015, at 21:40, Benjamin Greenman <
>> benjaminlgreen...@gmail.com> wrote:
>> >>
>> >> Have you or someone you know [1] ever thought:
>> >>
>> >> "Gee, I wish Typed Racket could figure out that ___ has type ___.
>> >> It's pretty obvious to me."
>> >>
>> >> Then the new "trivial" [2] library is here to help. If you're using
>> basic arithmetic (+, -, *, /), format strings, or regexp-match, just add a
>> colon to the end of your favorite operator.
>> >>
>> >> When a strong type really is obvious, you win!
>> >>
>> >> (require trivial/regexp)
>> >> (cond
>> >> [(regexp-match: #rx"f(o*)" "foobar")
>> >>  =>
>> >>  (lambda ([m : (List String String)]) (cadr m))]
>> >> [else
>> >>  "no match"])
>> >>
>> >> Please send bugs & feature requests to the issue tracker [3]. The
>> tracker's also a good place to complain about the choice of the name
>> "trivial" or the colon notation.
>> >>
>> >> [1] https://groups.google.com/forum/#!topic/racket-users/BfA0jsXrioo
>> >> [2] http://pkg-build.racket-lang.org/doc/trivial/index.html
>> >> [3] https://github.com/bennn/trivial/issues
>> >>
>> >>
>> >> ;; --- More Examples
>> >>
>> >> Before:
>> >> (+ 1 (if (= 0 (- 2 2)) 1 "x"))
>> >> ;; expected: Number, given: (U String One)
>> >>
>> >> (printf "hello ~a")
>> >> ;; raises runtime error
>> >>
>> >> (ann (regexp-match "f(o*)" "foobar")
>> >> (U #f (List String String)))
>> >> ;; Type Error, got type
>> >> ;;   (U #f (Pairof String (Listof (U False String
>> >>
>> >>
>> >> After adding (require trivial):
>> >>
>> >> (+ 1 (if (= 0 (-: 2 2)) 1 "x"))
>> >> ;; Success!
>> >>
>> >> (printf: "hello ~a")
>> >> ;; Compile-time error
>> >>
>> >> (ann (regexp-match "f(o*)" "foobar")
>> >> (U #f (List String String)))
>> >> ;; Success!
>> >>
>> >>
>> >> If a strong type isn't clear from the call site, you get standard
>> Typed Racket types.
>> >>
>> >> (let ([n 2]) (-: n 2))
>> >> ;; Type: Integer
>> >>
>> >> ((lambda ([f : (-> String Void)]) (f "~b" 'NaN))
>> >> printf:)
>> >> ;; Runtime error
>> >>
>> >> (regexp-match: "f(o*)|bar" "foo")
>> >> ;; Type: (U #f (Pairof String (Listof (U #f String
>> >>
>> >>
>> >> One more thing: there's a special form for compiling regular
>> expression patterns:
>> >>
>> >> (define-regexp: my-pat #rx"f(o*)")
>> >> ;; Also supports pregexp, byte-regexp, byte-pregexp
>> >>
>> >> (ann (regexp-match: my-pat "")
>> >> (U #f (List String String)))
>> >> ;; Success!
>> >>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups "Racket Users" group.
>> >> To unsubscribe from this group and stop 

Re: [racket-users] function minimization

2016-03-02 Thread Jerzy Karczmarczuk

'John Clements' via Racket Users cites Jens Axel Søgaard:

The root finder is the right tool.

Excellent. That makes a lot of sense. Given the setup, I think  h = 0.0001 is 
probably plenty small. It didn’t occur to me that I could differentiate 
numerically, rather than analytically. Thanks!
If your function is defined segment-wise, using numerical 
differentiantion might be dangerous, the program may take silly decisions.
*In general* minimizing a function by looking for zeros of the 
derivative is considered inefficient and not really stable. The root 
finder is not the right tool. You may use this derivative - if you wish 
- for the gradient descent procedure.


Jerzy Karczmarczuk

--
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] Appropriate open source license for a Racket based framework

2016-03-02 Thread Matthew Butterick
FWIW the LGPL is more restrictive than MIT. I license my Racket packages under 
the LGPL mostly for consistency. But the practical benefit is that I can copy 
Racket code into the package if I want to. I wouldn't be able to do that if I 
were using MIT (because the MIT license would be promising rights in the code 
that are not mine to give away). The California bar would want me to add that 
this is not legal advice, but rather general information from some random dude 
on a mailing list.


-- 
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] Appropriate open source license for a Racket based framework

2016-03-02 Thread Matthew Butterick
FWIW the LGPL is more restrictive than MIT. I license my Racket packages under 
the LGPL mostly for consistency. But the practical benefit is that I can copy 
Racket code into the package if I want to. I wouldn't be able to do that if I 
were using MIT (because the MIT license would be promising rights in the code 
that are not mine to give away). The California bar would want me to add that 
this is not legal advice, but rather general information from some random dude 
on a mailing list.

-- 
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] Strange loop

2016-03-02 Thread brendan
Ah! Of course. I never would have thought of that. Thank you.

-- 
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] Strange loop

2016-03-02 Thread Vincent St-Amour
Brendan,

You are correct, your program did error when you applied `Lam-body` to a
non-`Lam`. What happened is that, in the process of printing the error
message, it tried to print that non-`Lam` value, which called your
custom printer, and so on.

Does that make sense?

Vincent


On Wed, 02 Mar 2016 16:08:04 -0600,
brendan wrote:
> 
> Today I wrote and then fixed a bug that caused my program to enter an 
> infinite loop for reasons I don't understand.
> 
> The program is the output display formatting for a prototype relational 
> lambda calculus interpreter. First I took my two structs, Lam and App (using 
> symbols for variables), and implemented the gen:custom-write interface for 
> both, essentially following the example in the documentation:
> 
> 
> #lang racket
> 
> (define-struct Lam (var body)
>   #:methods gen:custom-write [(define write-proc (λ (v port mode)
>(write-lam v port mode)))])
> (define-struct App (func arg)
>   #:methods gen:custom-write [(define write-proc (λ (v port mode)
>(write-app v port mode)))])
> 
> (define (write-lam v port mode)
>   (define recur (make-recur port mode))
>   (fprintf port "λ~a." (symbol->string (Lam-var v)))
>   (recur (Lam-body v)))
> 
> (define (write-app v port mode)
>   (define recur (make-recur port mode))
>   (write-string "(" port)
>   (recur (App-func v))
>   (write-string " " port)
>   (recur (App-arg v))
>   (write-string ")" port))
> 
> (define (make-recur port mode)
>   (define aux (case mode
> [(#t) (lambda (v) (write v port))]
> [(#f) (lambda (v) (display v port))]
> [else (lambda (v) (print v port mode))]))
>   (λ (v)
> (if (symbol? v)
> (write-string (symbol->string v) port)
> (aux v
> 
> 
> It worked fine. Then I defined two new structs, Lam* and App*, representing 
> how the written notation groups consecutive lambdas and consecutive 
> applications together to save parentheses. I also wrote procedures to convert 
> from the simple representation to the new one. Finally, I implemented 
> gen:custom-write for the new structs:
> 
> 
> (define-struct Lam* (var* body) #:transparent
>   #:methods gen:custom-write [(define write-proc (λ (v port mode)
>(write-lam* v port 
> mode)))])
> 
> (define-struct App* (body*) #:transparent
>   #:methods gen:custom-write [(define write-proc (λ (v port mode)
>(write-app* v port 
> mode)))])
> 
> (define (write-lam* v port mode)
>   (define recur (make-recur port mode))
>   (define var-str (string-append* (map symbol->string (Lam*-var* v
>   (fprintf port "λ~a." var-str)
>   (recur (Lam*-body v)))
> 
> (define (write-app* v port mode)
>   (define recur (make-recur port mode))
>   (define (space-recur v)
> (write-string " " port)
> (recur v))
>   (define body* (App*-body* v))
>   
>   (write-string "(" port)
>   (recur (car body*))
>   (map space-recur (cdr body*))
>   (write-string ")" port))
> 
> (define (exp->exp* e)
>   (match e
> [(Lam _ _)
>  (define-values (var* body) (lam->var*+body e))
>  (Lam* var* body)]
> [(App _ _)
>  (App* (reverse (app->body* e)))]
> [else e]))
> 
> (define (lam->var*+body e)
>   (match e
> [(Lam v (and b (Lam _ _)))
>  (define-values (var* body) (lam->var*+body b))
>  (values (cons v var*) body)]
> [(Lam v b)
>  (values (list v) (exp->exp* b))]))
> 
> (define (app->body* e)
>   (match e
> [(App (and e1 (App _ _)) e2)
>  (cons (exp->exp* e2) (app->body* e1))]
> [(App e1 e2)
>  (list (exp->exp* e2) (exp->exp* e1))]))
> 
> 
> Since I knew that the new method implementations would be pretty similar to 
> the old ones, I followed my usual bad habit of cutting and pasting and then 
> making changes. And as happens more than I like to admit, I missed something. 
> Specifically, in the last line of write-lam*, where you now see Lam*-body, I 
> left it as Lam-body. When I tried displaying some simple test data, it went 
> into an infinite loop. When I tried to investigate with the debugger, I 
> learned that you can't break out of a loop in the debugger.
> 
> Anyway, long-story->short, I fixed the error, but now I'm puzzled. Shouldn't 
> the program have stopped with an error message when Lam-body was applied to a 
> non-Lam?
> 
> -- 
> 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.

-- 
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 

[racket-users] Strange loop

2016-03-02 Thread brendan
Today I wrote and then fixed a bug that caused my program to enter an infinite 
loop for reasons I don't understand.

The program is the output display formatting for a prototype relational lambda 
calculus interpreter. First I took my two structs, Lam and App (using symbols 
for variables), and implemented the gen:custom-write interface for both, 
essentially following the example in the documentation:


#lang racket

(define-struct Lam (var body)
  #:methods gen:custom-write [(define write-proc (λ (v port mode)
   (write-lam v port mode)))])
(define-struct App (func arg)
  #:methods gen:custom-write [(define write-proc (λ (v port mode)
   (write-app v port mode)))])

(define (write-lam v port mode)
  (define recur (make-recur port mode))
  (fprintf port "λ~a." (symbol->string (Lam-var v)))
  (recur (Lam-body v)))

(define (write-app v port mode)
  (define recur (make-recur port mode))
  (write-string "(" port)
  (recur (App-func v))
  (write-string " " port)
  (recur (App-arg v))
  (write-string ")" port))

(define (make-recur port mode)
  (define aux (case mode
[(#t) (lambda (v) (write v port))]
[(#f) (lambda (v) (display v port))]
[else (lambda (v) (print v port mode))]))
  (λ (v)
(if (symbol? v)
(write-string (symbol->string v) port)
(aux v


It worked fine. Then I defined two new structs, Lam* and App*, representing how 
the written notation groups consecutive lambdas and consecutive applications 
together to save parentheses. I also wrote procedures to convert from the 
simple representation to the new one. Finally, I implemented gen:custom-write 
for the new structs:


(define-struct Lam* (var* body) #:transparent
  #:methods gen:custom-write [(define write-proc (λ (v port mode)
   (write-lam* v port mode)))])

(define-struct App* (body*) #:transparent
  #:methods gen:custom-write [(define write-proc (λ (v port mode)
   (write-app* v port mode)))])

(define (write-lam* v port mode)
  (define recur (make-recur port mode))
  (define var-str (string-append* (map symbol->string (Lam*-var* v
  (fprintf port "λ~a." var-str)
  (recur (Lam*-body v)))

(define (write-app* v port mode)
  (define recur (make-recur port mode))
  (define (space-recur v)
(write-string " " port)
(recur v))
  (define body* (App*-body* v))
  
  (write-string "(" port)
  (recur (car body*))
  (map space-recur (cdr body*))
  (write-string ")" port))

(define (exp->exp* e)
  (match e
[(Lam _ _)
 (define-values (var* body) (lam->var*+body e))
 (Lam* var* body)]
[(App _ _)
 (App* (reverse (app->body* e)))]
[else e]))

(define (lam->var*+body e)
  (match e
[(Lam v (and b (Lam _ _)))
 (define-values (var* body) (lam->var*+body b))
 (values (cons v var*) body)]
[(Lam v b)
 (values (list v) (exp->exp* b))]))

(define (app->body* e)
  (match e
[(App (and e1 (App _ _)) e2)
 (cons (exp->exp* e2) (app->body* e1))]
[(App e1 e2)
 (list (exp->exp* e2) (exp->exp* e1))]))


Since I knew that the new method implementations would be pretty similar to the 
old ones, I followed my usual bad habit of cutting and pasting and then making 
changes. And as happens more than I like to admit, I missed something. 
Specifically, in the last line of write-lam*, where you now see Lam*-body, I 
left it as Lam-body. When I tried displaying some simple test data, it went 
into an infinite loop. When I tried to investigate with the debugger, I learned 
that you can't break out of a loop in the debugger.

Anyway, long-story->short, I fixed the error, but now I'm puzzled. Shouldn't 
the program have stopped with an error message when Lam-body was applied to a 
non-Lam?

-- 
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] Appropriate open source license for a Racket based framework

2016-03-02 Thread Robby Findler
LGPL

On Thursday, March 3, 2016, Leif Andersen  wrote:

> So, if you're not actually shipping Racket with your framework, I
> don't think it really matters. And even if you are, as long as you
> make it possible to relink to my own copy of Racket, I think it's fine
> too (as Racket is under the GPL).
>
> (At least, I hope it's fine, as I also have projects under the X11/MIT
> license (nanopass).)
>
> ~Leif Andersen
>
>
> On Wed, Mar 2, 2016 at 12:25 PM, Brian Adkins  > wrote:
> > On Wednesday, March 2, 2016 at 12:17:55 AM UTC-5, Neil Van Dyke wrote:
> >> Brian Adkins wrote on 03/01/2016 11:31 PM:
> >> > Are there any particular license issues that I should be aware of in
> this regard?
> >>
> >> I don't know.  Looks like core Racket is now LGPLv3, which is pretty
> >> flexible about commercial uses.  I've been using LGPLv3 for almost all
> >> of my Racket packages since around 2009, and LGPLv2-something before
> >> that.  (One exception is that a financial data scraping package of mine
> >> is GPL, and I also was working on a Racket firmware that was GPL.)  The
> >> legal notice in the documentation of each of my packages says people can
> >> contact me about alternative licenses.  In the last 13 years, I recall
> >> only once someone asking about the license for one of my Racket/Scheme
> >> packages, and it turned out the person was fine with LGPLv3.
> >>
> >> Neil V.
> >
> > Thanks. I've decided to go with the MIT License initially, this is
> *very* early in the process, so if a license change was deemed to be
> worthwhile later, it would be fine.
> >
> > --
> > 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.
>
> --
> 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.
>

-- 
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] function minimization

2016-03-02 Thread 'John Clements' via Racket Users

> On Mar 2, 2016, at 10:29 AM, Jens Axel Søgaard  wrote:
> 
> The root finder is the right tool.
> 
> Add this below your program:

Excellent. That makes a lot of sense. Given the setup, I think  h = 0.0001 is 
probably plenty small. It didn’t occur to me that I could differentiate 
numerically, rather than analytically. Thanks!

John

> 
> (require math/flonum)
> 
> (define (df/dx x)
>   (define f badness)
>   (define h 0.0001) 
>   (define d (/ (- (f (+ x h)) (f (- x h)))
>(* 2.0 h)))
>   (if (zero? d)
>   +inf.0
>   d))
> 
> (plot (list (function df/dx)
> (function (λ (x) 0.0)))
>   #:width 1300
>   #:x-min 1
>   #:x-max 120
>   #:y-min -5e-8)
> 
>  
> (flbracketed-root df/dx 5.0e5  6e5)
> (flbracketed-root df/dx 7.5e5 10e5)
> 
> 
> The results are: 
> 514285.7058330256
> 817605.5857361854
> 
> I don't know what the "proper" value of h ought to be
> and how much it affects the results. (A few experiments
> show that the integer part ought to trustworthy).
> 
> Maybe you can combine the approach with golden section
> search to hone in on a more precise value?
> 
> /Jens Axel
> 
> 
> 
> 
> 
> 
> 2016-03-02 18:36 GMT+01:00 'John Clements' via Racket Users 
> :
> I’m trying to minimize a function. It’s a continuous function made up of 
> piecewise well-behaved functions of the form (k_0 / x) +( k_1 / x^2). It’s 
> not hard to solve these analytically, but since they’re piecewise functions 
> each with different coefficients, I figured I’d ask first: does the math 
> package have a built-in function minimization operator? I looked around a bit 
> and found the root-finder, but not a minimizer.
> 
> Well, what the heck; racket is compact, I might as well include some sample 
> code and a picture.
> 
> Any help appreciated!
> 
> 
> 
> #lang racket
> 
> (require math/statistics)
> 
> ;; this file tries to determine the "best-fit" l for each user.
> 
> ;; the model in this case is a one-parameter model, defining this
> ;; simplified learning function:
> 
> ;; f(t) = (1 - t/l) when 0 < t < l
> ;; f(t) = 0 when t >= l
> 
> (require plot)
> 
> (define example-sequence
>   '(#(0 1)
> #(40 2/9)
> #(70 3/9)
> #(80 0)
> #(100 0)))
> 
> (plot (list (points example-sequence)
> (lines example-sequence))
>   #:x-max 120
>   #:width 1300)
> 
> ;; this fitness function measures the mean squared distance
> ;; from the datapoints to Model_l.
> ;; I want to find the value of l that minimizes this function
> (define (badness l)
>   (mean 
>(for/list ([pt (in-list example-sequence)])
>  (match-define (vector t e) pt)
>  (expt (cond [(< t l) (- e (- 1 (/ t l)))]
>  [else e])
>2
> 
> (plot (function badness)
>   #:width 1300
>   #:x-min 1
>   #:x-max 120
>   #:y-min 0)
> 
> -- 
> 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.
> 
> 
> 
> -- 
> -- 
> Jens Axel Søgaard
> 



-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Jens Axel Søgaard
Could it be that the OS X 10.8.5 has something to do with it?
Does anybody else have an 10.8 (Mountain Lion) installation?

/Jens Axel


2016-03-02 20:39 GMT+01:00 vkelmenson via Racket Users <
racket-users@googlegroups.com>:

> On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
> > I recently downloaded Racket version 6.4. I have previously been using
> version 6.1. It is much slower than version 6.1. Several short functions
> run approx 20 times slower on 6.4 than 6.1. These were run at the same time
> on the sam matine in succession.
> > I am using Mac osX version 10.8.5
> >  Has anyone else noticed this?
>
> Obviously something is wrong with my setup. I uninstalled version 6.4 from
> my computer and reinstalled the dmg from the download site. It is still the
> same. I am not going to have access to my desktop for about 10 days. I will
> see what happens with a laptop.
>
> --
> 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.
>



-- 
-- 
Jens Axel Søgaard

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Neil Van Dyke
If your Racket install is good... You might have instrumentation-heavy 
settings in DrRacket, and/or the compilation of your files is somehow 
corrupted.  Or maybe the cause is with your computer.


Try running your program from the command line, and after deleting your 
"compiled" directories for your code and re-compiling your code.  And 
make sure that some non-Racket issue with your computer isn't slowing it 
down (check expensive running processes for CPU/RAM/I/O contention, 
check system logs for hardware errors, check that CPU is not scaling for 
battery-saving, etc.).


Neil V.

--
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] Re: Racket 6.4 very slow

2016-03-02 Thread vkelmenson via Racket Users
On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
> I recently downloaded Racket version 6.4. I have previously been using 
> version 6.1. It is much slower than version 6.1. Several short functions run 
> approx 20 times slower on 6.4 than 6.1. These were run at the same time on 
> the sam matine in succession.
> I am using Mac osX version 10.8.5
>  Has anyone else noticed this?

Obviously something is wrong with my setup. I uninstalled version 6.4 from my 
computer and reinstalled the dmg from the download site. It is still the same. 
I am not going to have access to my desktop for about 10 days. I will see what 
happens with a laptop.

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Jens Axel Søgaard
2016-03-02 19:26 GMT+01:00 vkelmenson via Racket Users <
racket-users@googlegroups.com>:


> Also: When I am typing in the interactions pane of 6.4 there is often a
> 1-2 second delay before my
> keystrokes show up.
>
>
It sounds as if something went wrong during the installation on Racket.
How did you install it?
If you compiled it yourself, you most likely forgot to run raco setup.
The downloads from download.racket-lang.org contains precompiled files.

/Jens Axel

-- 
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] Racketcon talk proposal deadline

2016-03-02 Thread Brian Adkins
Sounds good - I'll try and get a talk ready for our May 19 local meetup which 
will give me time to incorporate feedback before the end of May, then I'll have 
an additional three+ months of coding prior to Racketcon.

> On Mar 2, 2016, at 1:29 PM, Vincent St-Amour  
> wrote:
> 
> Hi Brian,
> 
> You're way in advance. :) I'm planning to send out the call for
> proposals later this month.
> 
> We don't usually have a hard deadline, but if you could send me your
> proposal by the end of May, that would be great! Does that work for you?
> 
> Vincent
> 
> 
> 
> 
> On Wed, 02 Mar 2016 11:50:56 -0600,
> Brian Adkins wrote:
>> 
>> This is very premature, but out of curiosity, when is the deadline for 
>> submitting talk proposals for Racketcon? I'd like to use the date as a 
>> motivational tool to help me make enough progress on the web framework to be 
>> talk-worthy!
>> 
>> Thanks,
>> Brian
>> 
>> -- 
>> 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.

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Stephen Chang
In general, times reported in DrRacket are unreliable.

See: 
https://docs.racket-lang.org/guide/performance.html#%28part._.Dr.Racket-perf%29

Try the command line. Here's what I get on my machine:

$ ~/racket61/bin/racket
Welcome to Racket v6.1.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3044 real time: 3051 gc time: 0
55

$ ~/racket62/bin/racket
Welcome to Racket v6.2.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3036 real time: 3046 gc time: 0
55

$ ~/racket63/bin/racket
Welcome to Racket v6.3.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3040 real time: 3045 gc time: 0
55

$ ~/racket64/bin/racket
Welcome to Racket v6.4.
-> (define (total n)
(for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3036 real time: 3041 gc time: 0
55



On Wed, Mar 2, 2016 at 1:31 PM, Matthias Felleisen  wrote:
>
> It sounds like your files are not compiled. Try
>
>  raco setup
>
> in a shell. You may need to supply some command line flags if your files are 
> half way compiled.
>
> (Your examples runs in 3200 ms on my Mac in Racket 6.4.1)
>
>
>
> On Mar 2, 2016, at 1:26 PM, vkelmenson via Racket Users 
>  wrote:
>
>> On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
>>> I recently downloaded Racket version 6.4. I have previously been using 
>>> version 6.1. It is much slower than version 6.1. Several short functions 
>>> run approx 20 times slower on 6.4 than 6.1. These were run at the same time 
>>> on the sam matine in succession.
>>> I am using Mac osX version 10.8.5
>>> Has anyone else noticed this?
>>
>> (define (total n)
>>  (for/sum ([x (in-range (+ 1 n))]) x))
>> (time (total 10))
>> in Racket 6.1 just now 5287 milliseconds. In Racket 6.4 102384 milliseconds.
>> Also: When I am typing in the interactions pane of 6.4 there is often a 1-2 
>> second delay before my
>> keystrokes show up.
>>
>> --
>> 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.
>
> --
> 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.

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread Matthias Felleisen

It sounds like your files are not compiled. Try 

 raco setup 

in a shell. You may need to supply some command line flags if your files are 
half way compiled. 

(Your examples runs in 3200 ms on my Mac in Racket 6.4.1)



On Mar 2, 2016, at 1:26 PM, vkelmenson via Racket Users 
 wrote:

> On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
>> I recently downloaded Racket version 6.4. I have previously been using 
>> version 6.1. It is much slower than version 6.1. Several short functions run 
>> approx 20 times slower on 6.4 than 6.1. These were run at the same time on 
>> the sam matine in succession.
>> I am using Mac osX version 10.8.5
>> Has anyone else noticed this?
> 
> (define (total n)
>  (for/sum ([x (in-range (+ 1 n))]) x))
> (time (total 10))
> in Racket 6.1 just now 5287 milliseconds. In Racket 6.4 102384 milliseconds.
> Also: When I am typing in the interactions pane of 6.4 there is often a 1-2 
> second delay before my 
> keystrokes show up. 
> 
> -- 
> 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.

-- 
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] function minimization

2016-03-02 Thread Jens Axel Søgaard
The root finder is the right tool.

Add this below your program:

(require math/flonum)

(define (df/dx x)
  (define f badness)
  (define h 0.0001)
  (define d (/ (- (f (+ x h)) (f (- x h)))
   (* 2.0 h)))
  (if (zero? d)
  +inf.0
  d))

(plot (list (function df/dx)
(function (λ (x) 0.0)))
  #:width 1300
  #:x-min 1
  #:x-max 120
  #:y-min -5e-8)


(flbracketed-root df/dx 5.0e5  6e5)
(flbracketed-root df/dx 7.5e5 10e5)


The results are:
514285.7058330256
817605.5857361854

I don't know what the "proper" value of h ought to be
and how much it affects the results. (A few experiments
show that the integer part ought to trustworthy).

Maybe you can combine the approach with golden section
search to hone in on a more precise value?

/Jens Axel






2016-03-02 18:36 GMT+01:00 'John Clements' via Racket Users <
racket-users@googlegroups.com>:

> I’m trying to minimize a function. It’s a continuous function made up of
> piecewise well-behaved functions of the form (k_0 / x) +( k_1 / x^2). It’s
> not hard to solve these analytically, but since they’re piecewise functions
> each with different coefficients, I figured I’d ask first: does the math
> package have a built-in function minimization operator? I looked around a
> bit and found the root-finder, but not a minimizer.
>
> Well, what the heck; racket is compact, I might as well include some
> sample code and a picture.
>
> Any help appreciated!
>
>
> #lang racket
>
> (require math/statistics)
>
> ;; this file tries to determine the "best-fit" l for each user.
>
> ;; the model in this case is a one-parameter model, defining this
> ;; simplified learning function:
>
> ;; f(t) = (1 - t/l) when 0 < t < l
> ;; f(t) = 0 when t >= l
>
> (require plot)
>
> (define example-sequence
>   '(#(0 1)
> #(40 2/9)
> #(70 3/9)
> #(80 0)
> #(100 0)))
>
> (plot (list (points example-sequence)
> (lines example-sequence))
>   #:x-max 120
>   #:width 1300)
>
> ;; this fitness function measures the mean squared distance
> ;; from the datapoints to Model_l.
> ;; I want to find the value of l that minimizes this function
> (define (badness l)
>   (mean
>(for/list ([pt (in-list example-sequence)])
>  (match-define (vector t e) pt)
>  (expt (cond [(< t l) (- e (- 1 (/ t l)))]
>  [else e])
>2
>
> (plot (function badness)
>   #:width 1300
>   #:x-min 1
>   #:x-max 120
>   #:y-min 0)
>
> --
> 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.
>



-- 
-- 
Jens Axel Søgaard

-- 
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] Racketcon talk proposal deadline

2016-03-02 Thread Vincent St-Amour
Hi Brian,

You're way in advance. :) I'm planning to send out the call for
proposals later this month.

We don't usually have a hard deadline, but if you could send me your
proposal by the end of May, that would be great! Does that work for you?

Vincent




On Wed, 02 Mar 2016 11:50:56 -0600,
Brian Adkins wrote:
> 
> This is very premature, but out of curiosity, when is the deadline for 
> submitting talk proposals for Racketcon? I'd like to use the date as a 
> motivational tool to help me make enough progress on the web framework to be 
> talk-worthy!
> 
> Thanks,
> Brian
> 
> -- 
> 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.

-- 
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] Writing a blank to a file

2016-03-02 Thread Matthias Felleisen

(with-output-to-string #; "marco.txt" (lambda () (printf " ")))

(Replace 'string' with 'file' and delete the comment char #;)


On Mar 2, 2016, at 1:12 PM, Marco Morazan  wrote:

> 
> Hi All,
> 
> I seem to recall I knew how to do this once, but can't recall the details.
> 
> How do we write a blank to a text file without the parallel bars appearing?
> 
> So, (write '| | outfile) produces | | in the file. I want to eliminate the 
> vertical bars.
> 
> Thanks,
> 
> Marco
> 
> -- 
> 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.

-- 
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] Writing a blank to a file

2016-03-02 Thread Neil Van Dyke

Marco Morazan wrote on 03/02/2016 01:12 PM:

How do we write a blank to a text file without the parallel bars appearing?

So, (write '| | outfile) produces | | in the file. I want to eliminate the 
vertical bars.


That quote and vertical bars are creating an unusual symbol.  Do you 
instead want to write a string or character?


(write-string " " outfile)
(display " " outfile)
(write-char #\space outfile)
(display #\space outfile)

Neil V.

--
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] Re: Racket 6.4 very slow

2016-03-02 Thread vkelmenson via Racket Users
On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
> I recently downloaded Racket version 6.4. I have previously been using 
> version 6.1. It is much slower than version 6.1. Several short functions run 
> approx 20 times slower on 6.4 than 6.1. These were run at the same time on 
> the sam matine in succession.
> I am using Mac osX version 10.8.5
>  Has anyone else noticed this?

(define (total n)
  (for/sum ([x (in-range (+ 1 n))]) x))
(time (total 10))
in Racket 6.1 just now 5287 milliseconds. In Racket 6.4 102384 milliseconds.
Also: When I am typing in the interactions pane of 6.4 there is often a 1-2 
second delay before my 
keystrokes show up. 

-- 
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] Writing a blank to a file

2016-03-02 Thread Marco Morazan
On Wednesday, March 2, 2016 at 1:15:30 PM UTC-5, Stephen Chang wrote:
> Use display? or set read-accept-bar-quote to #f

Thanks! Works like a charm! :-)

Marco

> 
> On Wed, Mar 2, 2016 at 1:12 PM, Marco Morazan  wrote:
> >
> > Hi All,
> >
> > I seem to recall I knew how to do this once, but can't recall the details.
> >
> > How do we write a blank to a text file without the parallel bars appearing?
> >
> > So, (write '| | outfile) produces | | in the file. I want to eliminate the 
> > vertical bars.
> >
> > Thanks,
> >
> > Marco
> >
> > --
> > 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.

-- 
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] Writing a blank to a file

2016-03-02 Thread Leif Andersen
To clarify what Stephen wrote there a bit, you should probably want to
only use `display` here. To a first approximation, `write` is used for
writing out values that you can read back in with `read`. (This
doesn't work in general and you actually want to make things
marshlable if that is your goal, but that's the general idea anyway.)

`display` on the other hand, is used for writing out arbitrary text to
`current-output-port`. For this reason, I tend to like `printf` and
`format` more than `display`.

~Leif Andersen


On Wed, Mar 2, 2016 at 1:15 PM, Stephen Chang  wrote:
> Use display? or set read-accept-bar-quote to #f
>
> On Wed, Mar 2, 2016 at 1:12 PM, Marco Morazan  wrote:
>>
>> Hi All,
>>
>> I seem to recall I knew how to do this once, but can't recall the details.
>>
>> How do we write a blank to a text file without the parallel bars appearing?
>>
>> So, (write '| | outfile) produces | | in the file. I want to eliminate the 
>> vertical bars.
>>
>> Thanks,
>>
>> Marco
>>
>> --
>> 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.
>
> --
> 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.

-- 
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] Re: Racket 6.4 very slow

2016-03-02 Thread vkelmenson via Racket Users
On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
> I recently downloaded Racket version 6.4. I have previously been using 
> version 6.1. It is much slower than version 6.1. Several short functions run 
> approx 20 times slower on 6.4 than 6.1. These were run at the same time on 
> the sam matine in succession.
> I am using Mac osX version 10.8.5
>  Has anyone else noticed this?

-- 
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] Writing a blank to a file

2016-03-02 Thread Stephen Chang
Use display? or set read-accept-bar-quote to #f

On Wed, Mar 2, 2016 at 1:12 PM, Marco Morazan  wrote:
>
> Hi All,
>
> I seem to recall I knew how to do this once, but can't recall the details.
>
> How do we write a blank to a text file without the parallel bars appearing?
>
> So, (write '| | outfile) produces | | in the file. I want to eliminate the 
> vertical bars.
>
> Thanks,
>
> Marco
>
> --
> 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.

-- 
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] Writing a blank to a file

2016-03-02 Thread Marco Morazan

Hi All,

I seem to recall I knew how to do this once, but can't recall the details.

How do we write a blank to a text file without the parallel bars appearing?

So, (write '| | outfile) produces | | in the file. I want to eliminate the 
vertical bars.

Thanks,

Marco

-- 
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] Re: farewell, sweet PLaneT

2016-03-02 Thread Brian Adkins
On Saturday, February 27, 2016 at 8:15:41 PM UTC-5, Neil Van Dyke wrote:
> OK, I've moved 23 of my Racket packages from PLaneT to the new package 
> system, and I plan to move several more.  Exactly what's been moved, and 
> is planned to move, is tracked at "http://www.neilvandyke.org/racket/;.
> 
> If you notice any problems related to this move, please email me.
> 
> Perhaps the only "important" package of mine not yet moved is my SICP 
> DrRacket support one.  That will package remain in PLaneT for now, for 
> stability for new students, until I have time to polish a few changes.  
> When my SICP support does move to the new package system, I suspect that 
> the package will be called `sicp2`, and that there will be a `#lang 
> sicp2` (and likely `#lang sicp2/ch1` etc.). There is a chance we will be 
> able to use `#lang sicp` without breaking backward-compatibility for anyone.
> 
> For expedience, the packages moved so far all have a dependency on 
> package `mcfly`.  I plan for this dependency to go away eventually, with 
> a forthcoming tools that wants the inline documentation in comments 
> beginning with ";;;", and that generates static `.scrbl` at packaging time.
> 
> Research notes: Moving the 23 packages took roughly 40 person-hours of 
> my time, over 9 calendar days.  A chunk of that being interim kludges to 
> McFly Tools, and another chunk to make my Web site automate a new way of 
> hosting packages and home pages.  Separate from those two chunks, there 
> were still significant per-package costs that would still be incurred by 
> someone moving a large number of packages between package systems, even 
> if they went barebones with only URL-into-my-github and minimal changes 
> -- such as bit-rot, new bureaucratic hoops, and 4 naming collisions of 
> various kinds.  I expect that my remaining to-be-moved packages, not 
> counting SICP, will each take between 15 minutes and 3 hours each.  I 
> have an idea how to make engaged open source sharing easier for third 
> party contributors, going forward,   (This is relevant to one of my 
> research interests, in open source ecology and process.)
> 
> Thanks to Matthew, Jay, and others, for their help with this.
> 
> Unclear yet whether Elton John will be doing a "candle in the wind" song 
> for PLaneT.
> 
> Neil V.

That's awesome - thanks Neil. I hope I didn't put undue pressure on you in my 
previous thread :)

-- 
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] Racketcon talk proposal deadline

2016-03-02 Thread Brian Adkins
This is very premature, but out of curiosity, when is the deadline for 
submitting talk proposals for Racketcon? I'd like to use the date as a 
motivational tool to help me make enough progress on the web framework to be 
talk-worthy!

Thanks,
Brian

-- 
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] function minimization

2016-03-02 Thread 'John Clements' via Racket Users
I’m trying to minimize a function. It’s a continuous function made up of 
piecewise well-behaved functions of the form (k_0 / x) +( k_1 / x^2). It’s not 
hard to solve these analytically, but since they’re piecewise functions each 
with different coefficients, I figured I’d ask first: does the math package 
have a built-in function minimization operator? I looked around a bit and found 
the root-finder, but not a minimizer.

Well, what the heck; racket is compact, I might as well include some sample 
code and a picture.

Any help appreciated!



#lang racket

(require math/statistics)

;; this file tries to determine the "best-fit" l for each user.

;; the model in this case is a one-parameter model, defining this
;; simplified learning function:

;; f(t) = (1 - t/l) when 0 < t < l
;; f(t) = 0 when t >= l

(require plot)

(define example-sequence
  '(#(0 1)
#(40 2/9)
#(70 3/9)
#(80 0)
#(100 0)))

(plot (list (points example-sequence)
(lines example-sequence))
  #:x-max 120
  #:width 1300)

;; this fitness function measures the mean squared distance
;; from the datapoints to Model_l.
;; I want to find the value of l that minimizes this function
(define (badness l)
  (mean 
   (for/list ([pt (in-list example-sequence)])
 (match-define (vector t e) pt)
 (expt (cond [(< t l) (- e (- 1 (/ t l)))]
 [else e])
   2

(plot (function badness)
  #:width 1300
  #:x-min 1
  #:x-max 120
  #:y-min 0)

-- 
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] Appropriate open source license for a Racket based framework

2016-03-02 Thread Leif Andersen
So, if you're not actually shipping Racket with your framework, I
don't think it really matters. And even if you are, as long as you
make it possible to relink to my own copy of Racket, I think it's fine
too (as Racket is under the GPL).

(At least, I hope it's fine, as I also have projects under the X11/MIT
license (nanopass).)

~Leif Andersen


On Wed, Mar 2, 2016 at 12:25 PM, Brian Adkins  wrote:
> On Wednesday, March 2, 2016 at 12:17:55 AM UTC-5, Neil Van Dyke wrote:
>> Brian Adkins wrote on 03/01/2016 11:31 PM:
>> > Are there any particular license issues that I should be aware of in this 
>> > regard?
>>
>> I don't know.  Looks like core Racket is now LGPLv3, which is pretty
>> flexible about commercial uses.  I've been using LGPLv3 for almost all
>> of my Racket packages since around 2009, and LGPLv2-something before
>> that.  (One exception is that a financial data scraping package of mine
>> is GPL, and I also was working on a Racket firmware that was GPL.)  The
>> legal notice in the documentation of each of my packages says people can
>> contact me about alternative licenses.  In the last 13 years, I recall
>> only once someone asking about the license for one of my Racket/Scheme
>> packages, and it turned out the person was fine with LGPLv3.
>>
>> Neil V.
>
> Thanks. I've decided to go with the MIT License initially, this is *very* 
> early in the process, so if a license change was deemed to be worthwhile 
> later, it would be fine.
>
> --
> 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.

-- 
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] Appropriate open source license for a Racket based framework

2016-03-02 Thread Brian Adkins
On Wednesday, March 2, 2016 at 12:17:55 AM UTC-5, Neil Van Dyke wrote:
> Brian Adkins wrote on 03/01/2016 11:31 PM:
> > Are there any particular license issues that I should be aware of in this 
> > regard?
> 
> I don't know.  Looks like core Racket is now LGPLv3, which is pretty 
> flexible about commercial uses.  I've been using LGPLv3 for almost all 
> of my Racket packages since around 2009, and LGPLv2-something before 
> that.  (One exception is that a financial data scraping package of mine 
> is GPL, and I also was working on a Racket firmware that was GPL.)  The 
> legal notice in the documentation of each of my packages says people can 
> contact me about alternative licenses.  In the last 13 years, I recall 
> only once someone asking about the license for one of my Racket/Scheme 
> packages, and it turned out the person was fine with LGPLv3.
> 
> Neil V.

Thanks. I've decided to go with the MIT License initially, this is *very* early 
in the process, so if a license change was deemed to be worthwhile later, it 
would be fine.

-- 
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] Correct/Recommended way to provide macros from typed/racket

2016-03-02 Thread Asumu Takikawa
Hi Rodrigo,

Sorry for the late response.

On 2016-02-24 17:22:11 -0800, Rodrigo Setti wrote:
> Naturally macros from typed/racket cannot be used by untyped code, so I was
> experimenting with some organization options to isolate the macros in an
> untyped environment... I thought about using another module that requires the
> TR code and define the macros in untyped

Using another module sounds sensible to me, but that requires that the bindings
your macro depends on are actually exported. Though you could organize your
project so that the typed modules are in a "private" folder and avoid exporting
them from your "public" interface.

I can't think of a safe way to do this if you don't want to export any private
typed definitions.

It is, however, possible to do this unsafely with the `unsafe-provide` form
from `typed/racket/unsafe`.

Cheers,
Asumu

-- 
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.