It looks like "partitions2.rkt" ends up calling a contract-wrapped
variant of `exact-zero?`. If I change `ref!` to
(define (ref! n thnk)
(let ([v (vector-ref cache n)])
(if (zero? v)
(let ([new-v (thnk)])
(vector-set! cache n new-v)
new-v)
v)))
the
I have been interested in the Lisp family of languages for a while. My short
term reason for studying the book is to get a handle on Scheme for programming
on the Android platform.
Steve
Sent from Yahoo Mail on Android
Racket Users list:
http://lists.racket-lang.org/u
Yes, the `engine` function is like `thread`: it captures parameter
values at the point that the engine is created.
I'll fix the docs.
At Sat, 28 Jun 2014 21:35:58 -0400, Neil Van Dyke wrote:
> With the "racket/engine" module, is the "engine" procedure supposed to
> capture the Racket parameter v
Steve, welcome to Racket.
Regarding your Scheme questions... Unless you have an unusual reason
that you need to use some Scheme dialect, rather than Racket[*]... then
I strongly suspect that you want to just learn Racket for now, without
everyone getting confused, talking about the various dia
Hi Scott,
On Sat, 28 Jun 2014 12:05:39 -0700
Steve Graham wrote:
> When you're writing your program, do you enter statements in the top
> window or in the bottom one?
I'm not much of a DrRacket user myself. Nevertheless, it has nice
features.
In DrRacket you enter definitions in the top windo
On Sat, 28 Jun 2014 11:15:27 -0700
Steve Graham wrote:
> Hello, all. I just purchased Realm of Racket and am working my way
> through it. Although I've been programming for 30+ years, most of
> that has been with procedural languages (MUMPS, FORTRAN and COBOL) on
> character-based medical infor
With the "racket/engine" module, is the "engine" procedure supposed to
capture the Racket parameter values that will be used for the proc when
"engine-run" is applied? Rather than the parameters coming from the
dynamic extent in which "engine-run" is applied?
The example below shows that para
Hi Lawrence
In Peter Norvig's examples (e.g. http://norvig.com/sudoku.html), he applies
a functional style to most of his problem-solving, and to his Python
programming. Unsurprising given his background as a Lisp and AI doyen.
His Udacity course on Design of Computer Programs --
https://www.udac
When you're writing your program, do you enter statements in the top window or
in the bottom one? Do you have to define a function first before including it
in another function?
Steve
Racket Users list:
http://lists.racket-lang.org/users
Hello, all. I just purchased Realm of Racket and am working my way through it.
Although I've been programming for 30+ years, most of that has been with
procedural languages (MUMPS, FORTRAN and COBOL) on character-based medical
information systems (i.e. reports, EDI and utilities). This is one
Hi Eric,
Thanks for taking a look.
On my computer (mac) your vector version is 3 times faster than the hash one:
cpu time: 189 real time: 189 gc time: 3
cpu time: 53 real time: 53 gc time: 0
cpu time: 186 real time: 185 gc time: 3
cpu time: 58 real time: 58 gc time: 0
cpu time: 199 real time:
I took a look and for a while nothing I did sped it up, (likely
already racket was doing the optimizations I was doing by hand). But I
got a factor of 4 speed up on the vector code over the hash code by
not checking for exact 0, but instead using #f as the sentinal value.
Growing the vector by a a
When calling partitions once only the vector grows once only. Another case is
when partitions is called many times with increasing argument. In that case the
vector has to be copied every time. Therefore I would prefer the mutable hash.
I have thought of combining the two seperate loops for nega
The vector grows only once, so that's not it.
Below is a version where vector-ref! was removed.
This brings the timings closer to each other.
It seems that the hash version still is slightly faster though.
Is there anything else that can be improved?
#lang typed/racket/base
(provide partitions r
Possible culprit: growing the vector by 1 instead of by powers of 2.
Also, vector-ref! may not be especially fast. In particular, it always applies
a higher-order function, but hash-ref! only does that when an entry is missing.
Neil
Sent from my iPhone
> On Jun 28, 2014, at 7:04 AM, "Jos Koot"
On Fri, Jun 27, 2014 at 11:49:57AM -0400, Hendrik Boom wrote:
> On Wed, Jun 25, 2014 at 08:49:32PM -0500, Lawrence Bottorff wrote:
>
> > I see a huge differential between the high quality of Racket and the fact
> > that its popularity is low. Then again, perhaps Racket is where Python was
> > ten
Here's another approach:
#lang racket/base
(require (for-syntax racket/base)
web-server/dispatch)
(begin-for-syntax
(define-syntax-rule (in-stx-list l)
(in-list (syntax->list l
(define-syntax (nested-dispatch-rules stx)
(syntax-case stx ()
[(_ [(prefix ...) [(suffix ...)
Thanks for the conversion. I hope the code can be useful.
Strange timing differences. I would expect a vector to be faster, but I am no
expert on the inside of Racket. Looking at profiles with (partitions 1) I
see no special parts taking relatively exorbitant much more time in one version
t
Hi,
I have converted your code to Typed Racket and made two versions.
The first version use a hash as cache and the second version us a vector.
Timings show that the vector version is 1.5 to 2 times slower than the
hash version.
I don't understand this. Is there anything that can be done to impr
Thank you!
Sat, 28 Jun 2014 09:41:38 +0200 от "Jos Koot" :
>#lang racket
>
>(define-syntax (set!-values* stx)
> (syntax-case stx ()
> ((_ (var ...) values-expr)
> (with-syntax (((local-var ...) (generate-temporaries #'(var ...
> #'(let-values (((local-var ...) values-expr))
> (set!*
Sorry, forgot to post the following to the users list.
Hi,
count partitions, much faster and exact.
You may want to put the hash or part of it within function p such as to
avoid spllling much memory.
Jos
#lang racket
(require math/number-theory)
(define p-hash (make-hash '((0 . 1
(define (
#lang racket
(define-syntax (set!-values* stx)
(syntax-case stx ()
((_ (var ...) values-expr)
(with-syntax (((local-var ...) (generate-temporaries #'(var ...
#'(let-values (((local-var ...) values-expr))
(set!* var local-var) ...)
(define-syntax (set!* stx)
(syntax-case st
On June 28, 2014, at 12:43AM, Roman Klochkov wrote:
Racket Users list:
http://lists.racket-lang.org/users
On June 28, 2014, at 12:43AM, Roman Klochkov wrote:
Racket Users list:
http://lists.racket-lang.org/users
24 matches
Mail list logo