On 19/06/2015 21:24, Luke Miles wrote:
Say I have a list ls and I want to produce a list of
lists where the i'th list has the i'th element of ls tripled,
but all other elements are the same.
e.g. '(3 5 7) = '((9 5 7) (3 15 7) (3 5 21))
What is a fast way to do this?
I could do a loop with
Hi Luke,
What are the result on lists of length 1000?
Also can you post the benchmarking code?
/Jens Axel
2015-06-19 22:33 GMT+02:00 Luke Miles rashreportl...@gmail.com:
I timed all these with `sqr` on a list of 1 `(random)`.
Luke's (my) first one:
cpu time: 4706 real time: 4699 gc
Are the x, y, and z variables meant to be defined outside the macro by the user
as in:
(let ([x “something”] [y “something else”] [z “and something else”])
(Loop ….))
?
Or should the Loop macro create a (let ([x 0] [y 0] [z 0]) ….) for you instead?
On Jun 19, 2015, at 5:58 PM, Thomas
I was intending for that example to have the variables be defined outside the
macro, but being able to create the (set! ...) forms outside should mean I
could also hypothetically create let/define-values forms. This is why I
originally specified being able to effect generation of both prologue
Hello,
Use (define-values (a b c) (http-send-recv ...)) as a remplacement for define
when you receive multiple values.
Or (let-values ([(a b c) (http-send-recv ...)]) ...) the same idea but for let.
You can search for binding ending with '-values'.
see
A more efficient version using append-reverse from srfi/1.
#lang racket
(require (only-in srfi/1 append-reverse))
(define (list-splits xs)
(define (loop ys zs) ; xs = (append (reverse ys) yz)
(match zs
['() '()]
[(cons z zs*) (cons (list ys zs)
It's unlikely that an implementation using continuations would be
faster than one that does not.
An idiomatic solution might look like:
(define (map-once fn xs)
(for/list ([i (in-range (length xs))])
(for/list ([(x j) (in-indexed (in-list xs))])
(cond [(= i j) (fn x)]
My 1000 numbers were so small that they weren't reliable.
Change the `num-runs-per-f` and experiment yourself, if you'd like.
The code is attached.
--
You received this message because you are subscribed to the Google Groups
Racket Users group.
To unsubscribe from this group and stop receiving
#lang racket
(define (list-splits xs)
(define (loop ys zs) ; xs = (append (reverse ys) yz)
(match zs
['() '()]
[(cons z zs*) (cons (list ys zs)
(loop (cons z ys) zs*))]))
(loop '() xs))
(define (map-once f xs)
(for/list ([ys+zs
I timed all these with `sqr` on a list of 1 `(random)`.
Luke's (my) first one:
cpu time: 4706 real time: 4699 gc time: 3673
Luke's second one:
cpu time: 5401 real time: 5393 gc time: 4136
Jon's first one:
cpu time: 9734 real time: 9728 gc time: 8007
Jon's second one (tested on a vector of
Sure, here's a toy example.
This code:
(Loop 10
(begin
(define-values
[dx dy dz]
(values 0 0 0))
; Some calculation here
(Accum x dx)
(Accum y dy)
(Accum z dz)))
Should desugar into this code:
(letrec
([loop
For changes like typoes, Github has a pencil button at the top of its
source view that simplifies the pull-request process.
https://help.github.com/articles/editing-files-in-another-user-s-repository/
Vincent
At Thu, 18 Jun 2015 21:44:50 -0400,
Alexander D. Knauth wrote:
You could
Racket version 6.2 is now available from
http://racket-lang.org/
With this release we are taking a major step forward to get our user
community even more involved than in the past. Over the past six months,
we have re-organized the Racket code base into a small core code repo
and many other
Hi Jay,
Sorry for this newbie question, but how do I grab just the third value.
Everything I try gets me an arity mismatch:
result arity mismatch;
expected number of values not received
expected: 1
received: 3
values...:
#HTTP/1.1 200 OK
'(#Cache-Control: no-store, no-cache,
While Racket enables the construction of new frameworks and languages,
indeed encourages it, I think rackunit has proven its value and many of
us use it as a de factor standard. (Some also use Eli's test library,
because they enjoy the simpler syntax. But it's not quite ready and
I am
Hi All,
I'm trying to figure out how best to implement the following pattern of macro
behavior:
Let's say we are writing Loop macro that implements a looped computation over a
specified body. I would like to then be able to
(a) introduce additional Loop-specific macros that are defined only
On 06/19/2015 03:07 PM, Thomas Dickerson wrote:
Hi All,
I'm trying to figure out how best to implement the following pattern of macro
behavior:
Let's say we are writing Loop macro that implements a looped computation over a
specified body. I would like to then be able to
(a) introduce
Is `rackunit` to be used for all core Racket testing, long-term?
Is there any other Racket testing stuff on the horizon?
(Reason for asking: I'm about to standardize unit/regression testing for
a large Racket-based system. I need to decide whether to build it upon
`rackunit` at some level.)
Say I have a list ls and I want to produce a list of
lists where the i'th list has the i'th element of ls tripled,
but all other elements are the same.
e.g. '(3 5 7) = '((9 5 7) (3 15 7) (3 5 21))
What is a fast way to do this?
I could do a loop with appending.
(define (map-once f ls)
(let M
19 matches
Mail list logo