Wow, thanks for all the creative solutions! After many years of
programming, I'm still so floored by what a creative and artistic endeavor
it is... and like all artistic endeavors, over time one develops a certain
taste and style. Certain solutions really appeal over others.
Thanks again, learni
;and without having to discard first two elements->
(build-list 21 (compose (λ (x) (/ (* x
(+ x 1))
2))
add1))
Racket Users list:
http://lists.racket-lang.org/users
(build-list 22 (λ (x) (/ (* x
(- x 1))
2)))
Discard the first two values from the list.
R./
Zack
Racket Users list:
http://lists.racket-lang.org/users
> From: Joe Gilray
> To: Racket mailing list
> Subject: [racket] idiomatic and fast
>
> I'm trying to come up with the most idiomatic way to generate triangle
> numbers that is also fast:
>
> (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j))
>
> works but is slow because it regen
Here's a solution based on for/fold that hasn't been suggested
yet. Runs in O(n) time.
(let-values ([(results last-sum)
(for/fold ([sofar '()]
[value 1])
([i (in-range 2 22)])
(values (cons value sofar)
On 28/04/12 22:54, Joe Gilray wrote:
>
> (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j))
>
> works but is slow because it regenerates the sums each time
>
> (define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s)
>
> is fast, but ugly.
>
> How do I keep the sum in an idioma
I don't know if I could ever be a resource on "most idiomatic",
especially since I basically never use any of the for/et ceteras but
this feels reminiscent of "The Little Schemer" to me (except for the
internal define instead of letrec):
(define (make-triangles to-n)
(define (next-triangle last-
My opinion is to start by *not* using "for"-something forms. I'd
suggest starting with named-"let" or recursive named procedures, and
going from there. I think you'll find yourself wanting "set!" less once
you kick "for"-something to the curb.
I think that "for"-something forms are for peopl
I have forked the crypto package to perform these actions for my own code
and to fix some other problems with post 1.0.0 versions of OpenSSL. I
submitted a bug report that at least removes the errors when we go to later
OpenSSL versions, but haven't seen any response. I don't have the
throughput to
(whoops, should reply all)
I have a macro that does for/fold behavior on some arguments and for/lists on
the other. It's fairly handy.
Here's my solution with that macro:
(let-values ([(_ result)
(for/fold/lists ([s 0]) (result) ([i (in-range 1 21)])
(v
Hi,
I'm trying to come up with the most idiomatic way to generate triangle
numbers that is also fast:
(for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j))
works but is slow because it regenerates the sums each time
(define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s)
is
Hi there,
I'm working with the crypto lib from PLaneT. It actually works well, so far,
thanks for the wrappers (it's a Scheme interface to OpenSSL).
My question is, how do I turn off padding, i.e. what do I have to pass (and
where) as an additional parameter to e.g.
(define dummy (encrypt ciph
Fix pushed. Thanks!
Robby
On Sat, Apr 28, 2012 at 4:24 AM, Laurent wrote:
>
>
> On Fri, Apr 27, 2012 at 21:54, Laurent wrote:
>>
>>
>>
>> On Fri, Apr 27, 2012 at 21:08, Deren Dohoda
>> wrote:
>>>
>>> Sorry, supposed to be to all:
>>>
>>> WinXP, DrRacket 5.2
>>> Edit: Show Active Keybindings:
>
If anyone is maintaining a third-party package and wants to know when
we start testing a release candidate, tell me and I'll add you to a
list of people that are notified when we start to test for a new
release.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
On Fri, Apr 27, 2012 at 21:54, Laurent wrote:
>
>
> On Fri, Apr 27, 2012 at 21:08, Deren Dohoda wrote:
>
>> Sorry, supposed to be to all:
>>
>> WinXP, DrRacket 5.2
>> Edit: Show Active Keybindings:
>>
>> string: expects argument of type ; given f1
>>
>
> Indeed. I'm not sure, but this one might b
15 matches
Mail list logo