Re: [racket-users] My gmail auto receives new top-level entries from [Racket Users] but not reply entries...

2019-01-15 Thread Pierpaolo Bernardi
On Wed, Jan 16, 2019 at 12:04 AM infodeveloperdon wrote: > > Hi, > It has been awhile since I've been posting questions to [Racket Users]. > Previously, my gmail account would receive both my query entry and every > reply entry. (Of course, it actually received all entries and replies entered >

Re: [racket-users] Regexp question matching a whole string

2018-04-22 Thread Pierpaolo Bernardi
On Sun, Apr 22, 2018 at 10:40 PM, Zelphir Kaltstahl wrote: > Ah OK, I understand that additional newline. Since the code matching the > regex is run before that newline gets in, the newline will be on the > input port. > > In DrRacket I observe the following: > > (I remembered that there are negat

Re: [racket-users] chaining operations on bignum not scalable

2017-07-29 Thread Pierpaolo Bernardi
Il giorno 29 luglio 2017, alle ore 20:48, rom cgb ha scritto: >Hi, >Probably due to all operations not being in-place, chaining operations on >bignums is very costful. >for example, using bitwise-bit-field[1] on bignums is atrocious. >I also tried >  (define (reverse-bits n) >    (for/fold ([

Re: [racket-users] eval:check and floating-point precision

2016-11-26 Thread Pierpaolo Bernardi
On Sat, Nov 26, 2016 at 11:37 AM, luis.osa.gdc wrote: > Hi, everyone! > ``` > (check-= (t-test bacteria-a bacteria-b) 13.0 0.1) > ``` > > In short: is there a way to specify tolerance in `eval:check`? Perhaps, instead of checking directly the result of t-test you can check (good-enough (t-test .

Re: [racket-users] How to 'apply' a function with optional parameters?

2016-10-29 Thread Pierpaolo Bernardi
On Sat, Oct 29, 2016 at 5:31 PM, wrote: > At the certain point of the program I get > a list as parameter 'lst', which contains > the sublists of strings. I wrote this > function: > > > (define (to-txt lst) > (if (empty? lst) > lst > (let ((line (car lst))) > (begin > (di

Re: [racket-users] TR issue with the type of expt

2016-09-27 Thread Pierpaolo Bernardi
On Tue, Sep 27, 2016 at 3:23 PM, Tim Brown wrote: > I believe (because I can’t think of a counterexample) that > (expt Real Real) is never Complex; and therefore expt can be of type > (Real Real -> Real). What about (expt -1 1/2) ? -- You received this message because you are subscribed to the

Re: [racket-users] Can't display accented characters at the Windows console

2016-09-02 Thread Pierpaolo Bernardi
Hello, > I'm new to Racket and would like to know what is the trick to make accented > characters display correctly at the Windows command prompt. For example, > when I write at the Racket prompt: >> "número" > then it returns: > "n´┐¢mero" Here you can read an old discussion about this topic: h

Re: [racket-users] Case vs. Match

2016-06-03 Thread Pierpaolo Bernardi
On Sat, Jun 4, 2016 at 1:23 AM, Gustavo Massaccesi wrote: > > [...] I saw in the docs that case specifically mentions it can > distribute in log(n) time [...] > but both expand to a bunch of nested if, nothing fancy that may run in > O(log(N)). > (I don't expect that it has a smarter implementat

Re: [racket-users] Problem with # and mutable lists

2016-04-10 Thread Pierpaolo Bernardi
On Sun, Apr 10, 2016 at 1:29 PM, Joan Martin wrote: > Hello, > I try to write a programme (a game), where I use lots of mutable lists (named > environment).Something like this: > (define environment > (mcons (mcons (mcons 1 (mcons (mcons 2(mcons 5(mcons 8 '('() )) > (mcons

Re: [racket-users] a little bug

2016-02-05 Thread Pierpaolo Bernardi
On my system it behaves almost exactly as described by Jon (6.3, windows). The one difference is that DrRacket hasn't crashed yet, but the Task manager reports one processor at 100% and memory use slowly growing. Currently is at 7.5 GB. On Fri, Feb 5, 2016 at 2:29 PM, Anthony Carrico wrote:

Re: [racket-users] (help ...) form in command-line REPL vs. Dr. Racket

2016-01-26 Thread Pierpaolo Bernardi
On Wed, Jan 27, 2016 at 12:46 AM, Brian Adkins wrote: > Ok, this is odd, it works with both Chrome and Safari *if* they're not > already open when (help filter) is evaluated. If they are already open, the > URL is missing the anchor. In my case, the default browser is Chrome, and it was alread

Re: [racket-users] (help ...) form in command-line REPL vs. Dr. Racket

2016-01-26 Thread Pierpaolo Bernardi
On Wed, Jan 27, 2016 at 12:35 AM, Brian Adkins wrote: > Just out of curiosity, does this work for anyone else? In other words, in the > Dr. Racket repl: > > (require racket/help) > (help filter) > > does that scroll down to the filter description in section 4.9, or is your > URL missing the anc

Re: [racket-users] Counterintuitive performance results

2016-01-08 Thread Pierpaolo Bernardi
I tried swapping the two expressions. The result is that the one executing first is always slower than the one executing second. So, probably the timing is dominated by some memory/GC/locality effect rather than the difference between set-member? and set-members? On Fri, Jan 8, 2016 at 10:29 PM,

Re: [racket-users] reading UTF-16 from a file

2015-11-13 Thread Pierpaolo Bernardi
On Fri, Nov 13, 2015 at 9:45 AM, Tim Hanson wrote: > hi, > > I was hoping yesterday to read UTF-16 characters from a file I think you need reencode-input-port. > p.s. maybe there's an easier way to get an arbitrary counter than what i did > here? > > (define (integers-starting-from n) > (stre

Re: [racket-users] Re: racket users fight for their right to colon keywords

2015-10-22 Thread Pierpaolo Bernardi
On Thu, Oct 22, 2015 at 8:09 PM, Andrew Gwozdziewycz wrote: > Surely there are books about this subject. Does anyone have any > recommendations for future self? This course has a module on voting theory: https://www.coursera.org/course/mathphil The course is not heavy-handed and can be taken ev

Re: [racket-users] racket users fight for their right to colon keywords

2015-10-14 Thread Pierpaolo Bernardi
On Wed, Oct 14, 2015 at 11:34 PM, Neil Van Dyke wrote: > Alex Knauth wrote on 10/14/2015 04:37 PM: >> >> You can use >> #lang colon-kw racket >> for :kw syntax, and >> #lang kw-colon racket >> for kw: syntax. > > > If the standard `#lang racket` and `#lang racket/base` don't support > `:keyword` o

Re: [racket-users] Question about structuring recursive code

2015-09-23 Thread Pierpaolo Bernardi
On Wed, Sep 23, 2015 at 6:18 PM, Kaushik Ghose wrote: > Can I have any statements in this block that I could have in a (define ...) > block? Can I have (defines ) for example? Yes, and yes :) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. T

Re: [racket-users] Question about structuring recursive code

2015-09-23 Thread Pierpaolo Bernardi
On Wed, Sep 23, 2015 at 3:20 PM, Kaushik Ghose wrote: > e.g. > > (define (f-recur x y) > (if (< x 1) > 10 > (f-recur-2 x y))) > > (define (f-recur-2 x y) > ... something complex here > (f-recur x' y') (define (f-recur x y) (cond ((< x 1) 10) (else

Re: [racket-users] `divides?` from math/number-theory slow?

2015-08-24 Thread Pierpaolo Bernardi
On Mon, Aug 24, 2015 at 1:25 PM, Jens Axel Søgaard wrote: > It looks very odd to me. Maybe this is due to calling TR functions from plain Racket? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receivin

Re: [racket-users] What limits would you put on racket?

2015-07-27 Thread Pierpaolo Bernardi
On Fri, Jul 24, 2015 at 4:31 PM, Hendrik Boom wrote: > You might be interested in the language Styx, the language that goes with > the Inferno operating system. I believe it uses reference counting up > front, with full garbage collection as a backstop. The language is called Limbo. Styx is In

Re: [racket-users] Re: How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 11:40 PM, Pekka Niiranen wrote: > Thanks Sir, > > This was exactly what I tried to reason. > It never occured to me that parameter "failure" can be used > in both for/fold -constructs. I must fix once again my code. Sigh. I fixed a mistake, and renamed one of the two failu

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 11:11 PM, Stephen Chang wrote: > Perhaps I don't understand the problem, but why is the inner loop necessary? He asked how to test each value against each of the limit pairs. I assume this is a simplified/demo problem and in the problem he really cares about there's a rea

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
On Fri, Jul 10, 2015 at 10:45 PM, Pierpaolo Bernardi wrote: > If I understand correctly the spec, this should do what you ask? which, fixing the typo, becomes: (define (validate-ranges value-list low-list high-list) (for/fold ((failures 0)) ((low (in-list low-l

Re: [racket-users] How to return summary from the inner loop?

2015-07-10 Thread Pierpaolo Bernardi
If I understand correctly the spec, this should do what you ask? (define (validate-ranges value-list low-list high-list) (for/fold ((failures 0)) ((low (in-list value-list)) (high (in-list high-list))) (for/fold ((failures 0)) ((value (in-list value-lis

Re: [racket-users] Room for descriptions

2015-07-03 Thread Pierpaolo Bernardi
On Fri, Jul 3, 2015 at 8:36 PM, Neil Van Dyke wrote: > BTW, Emacs users can get this feature through Quack. > The feature turns causes a typed "[" to insert "(". > > Separately, typed "]" always inserts the character to agree with the > matching open paren/bracket. > > To really insert "[", do th

Re: [racket-users] Room for descriptions

2015-07-03 Thread Pierpaolo Bernardi
BTW, since you are looking at the preferences, I wish there was a way to have automatic conversion of square brackets to parentheses *always*. That is, I don't want square brackets in my racket code, but I like the convenience of typing them over typing parentheses. Looks like a combination of pre

Re: [racket] Typed Racket frustration

2015-01-23 Thread Pierpaolo Bernardi
On Sat, Jan 24, 2015 at 7:43 AM, Matthew Butterick wrote: > PS. I remain curious what one can do with an immutable `hash` function that > takes no arguments, but perhaps it is meant to be a TR koan. It has about the same uses as an immutable empty list. You start with an empty table then add thi

Re: [racket] Calculating cumulative sum of the list

2015-01-22 Thread Pierpaolo Bernardi
Here's a straightforward way: (define (cumulative-sum list) (let loop ([list list] [acc 0]) (if (null? list) list (let ([s (+ (first list) acc)]) (cons s (loop (rest list) s)) On Thu, Jan 22, 2015 at 2:53 PM, Alexandr M wrote: > Hello, > > I am trying to replicate

Re: [racket] Racketrivia: Using ' as an identifier suffix

2015-01-08 Thread Pierpaolo Bernardi
On Thu, Jan 8, 2015 at 10:49 PM, Neil Van Dyke wrote: > I generally recommend against using non-ASCII characters in Racket source > code. > > Besides the human readability question (and the searchability question), > non-ASCII still presents a significant risk of your characters getting > corrupte

Re: [racket] why a segfault on the command line, but not in DrRacket?

2014-12-30 Thread Pierpaolo Bernardi
Just for excluding any possibility of user error: do you use any unsafe features? On Tue, Dec 30, 2014 at 8:43 PM, Matthew Butterick wrote: > No, it's all Racket libraries. > > OTOH I may be the one causing the memory-management problems. The issues are > arising in my typesetting program, which

Re: [racket] find-system-path under debugger

2014-11-30 Thread Pierpaolo Bernardi
I think you need define-runtime-path instead. Here's an example of its use: ;; Access a file "data.txt" at run-time that is originally ;; located in the same directory as the module source file: (define-runtime-path sofa.dll (format "sofa-~a-~a~a" sofa-version arch "")) P. ===

Re: [racket] flood-fill?

2014-10-13 Thread Pierpaolo Bernardi
sing the code for (still lot of work to do): https://farm6.staticflickr.com/5599/15337830979_c4bccae56a_o.png https://farm4.staticflickr.com/3940/15337812549_5ec924e207_o.png P. > At Sat, 11 Oct 2014 20:59:09 +0200, > Pierpaolo Bernardi wrote: >> >> For the record, in case some

Re: [racket] flood-fill?

2014-10-11 Thread Pierpaolo Bernardi
ps://github.com/acmeism/RosettaCodeData/blob/master/Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt > > /Jens Axel > > > 2014-10-05 22:14 GMT+02:00 Pierpaolo Bernardi : >> Hello, >> >> here's a couple of dumb questions: I did not find a flood-fill method >

Re: [racket] flood-fill?

2014-10-05 Thread Pierpaolo Bernardi
On Sun, Oct 5, 2014 at 10:30 PM, Jens Axel Søgaard wrote: > Maybe this can be used? > > https://github.com/acmeism/RosettaCodeData/blob/master/Task/Bitmap-Flood-fill/Racket/bitmap-flood-fill.rkt Yes! Much better than mine. Thank you. However, it uses a straight deep-first recursion with no auxi

[racket] flood-fill?

2014-10-05 Thread Pierpaolo Bernardi
Hello, here's a couple of dumb questions: I did not find a flood-fill method for bitmaps. Am I right it's not there, or I missed it? I tried implementing one myself, but the result is way too slow to be useful. Any recommendation? Cheers P. Racket Users list: http://lis

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-08-11 Thread Pierpaolo Bernardi
On Mon, Aug 11, 2014 at 8:07 AM, Matthew Flatt wrote: > +1 > > In the grand scheme of things, using `eval` to solve a problem (because > you want to get something done now) is nowhere near as bad as, say, but, to come back to the original question, in order to not confuse further the OP: in this

Re: [racket] Use of map and eval to evaluate symbol in namespace

2014-07-26 Thread Pierpaolo Bernardi
On Sun, Jul 27, 2014 at 5:10 AM, Henry Lenzi wrote: > #lang racket > > #| > > Dear Racketeers - > > I would like to create a little function > that would write a line of a medical recipe. > > I would pass to "read" a shorthand form, > and the program would expand the text. Like so: > > When I answ

Re: [racket] FYI: A new Racket-powered startup

2014-02-05 Thread Pierpaolo Bernardi
On Wed, Feb 5, 2014 at 12:38 AM, Gustavo Massaccesi wrote: > Why are you using Racket, and why it's "better" than C? Can you make an example of something that's worse than C? Racket Users list: http://lists.racket-lang.org/users

Re: [racket] Generating comparable symbols

2014-01-15 Thread Pierpaolo Bernardi
On Wed, Jan 15, 2014 at 8:43 AM, Eric Dobson wrote: > I'm not sure what you mean by random, but does gensym do what you want? I think Marco means interned. Gensym produces uninterned symbols. AFAIK, and checking briefly the manual, there doesn't seem to exists a single function to do this. But i

Re: [racket] Problem around Creating Excutables

2014-01-02 Thread Pierpaolo Bernardi
On Thu, Jan 2, 2014 at 4:09 PM, 亀田馬志 wrote: > Is this O.K? or do I have to put (flush-output) every time after (display)? without flush-output what you write in the stream remains in a buffer and is actually written out only when the buffer is full. You must use flush-output when you want to be

Re: [racket] Problem around Creating Excutables

2014-01-01 Thread Pierpaolo Bernardi
On Thu, Jan 2, 2014 at 1:05 AM, 亀田馬志 wrote: > Does anybody know how to tell Racket's compiler "I wanna see this in UTF-8"? Are you sure that your DOS windows is using UTF-8? AFAIK if you do nothing racket sends UTF-8 to the console. Maybe your console is not using UTF-8. If this is the case yo

Re: [racket] ~r behavior with respect to the sign

2013-12-24 Thread Pierpaolo Bernardi
On Tue, Dec 24, 2013 at 4:30 PM, Dmitry Pavlov wrote: > Hello, > > It seems that ~r formatting function, when given a negative > number and a #:min-width argument, does not treat the "-" > character as part of the number bound by #:min-width, > and moreover, it detaches the "-" from the number: U

Re: [racket] hello..

2013-11-29 Thread Pierpaolo Bernardi
On Fri, Nov 29, 2013 at 9:25 PM, Robby Findler wrote: > To find other keys that do the same thing (there aren't any others, I don't > believe, that work in on all platforms with the default settings), you can > use the menu item "Show Active Keybindings" in the "Edit" menu. Search for > "put-prev

Re: [racket] hello..

2013-11-29 Thread Pierpaolo Bernardi
ESC-x and ALT-x usually are synonims. With ALT-x you can keep ALT pressed and repeat only the x. The ESC variant is useful on classical keyboards which do not have an ALT key or equivalent. On Fri, Nov 29, 2013 at 7:30 PM, Michael Jensen wrote: > I have a question/suggestion. if this is goi

Re: [racket] Why does this tail recursive list length function fail at cdr l at end of list?

2013-11-20 Thread Pierpaolo Bernardi
On Wed, Nov 20, 2013 at 12:09 PM, Bo Gus wrote: > My tail recursive implementation of length is like this: > > (define (length2 l) > (define (l-iter l count) > (if (null? 1) count > (l-iter (cdr l) (+ count 1 > (l-iter l 0)) > I am fairly new to scheme. What am I doing wrong?

Re: [racket] frequent crashes on Windows 7 64-bit

2013-10-30 Thread Pierpaolo Bernardi
On Tue, Oct 29, 2013 at 11:19 PM, Andrews, Kyle (KC) wrote: > I just tried running your code 3 times on `(main 7)' and twice on `(main 6)' > and it has crashed each time. But I was worried that somehow I was running > out of memory (even though I have 16 Gb available), I confirm the crashes (tr

Re: [racket] fuzzy set representation in Racket

2013-08-23 Thread Pierpaolo Bernardi
Why don't you simply use a hash-table? (mutable or immutable according to your need). On Fri, Aug 23, 2013 at 9:49 PM, Rian Shams wrote: > Hello All, > > My name is Rian and I am a new Racket user and a novice programmer (Racket > is my first language). First let me say that I am very grateful

[racket] Fwd: music mini-language

2013-08-10 Thread Pierpaolo Bernardi
(Neil, sorry for the duplicate.) Maybe abc notation is adeguate for such simple requirements, and it should be easy to implement. http://abcnotation.com/ On Sat, Aug 10, 2013 at 1:25 AM, Neil Van Dyke wrote: > Anyone currently working with music mini-languages in Racket? > > Reason I ask... In

Re: [racket] Why can't `Alt' be used as the Meta key in Windows?

2013-07-24 Thread Pierpaolo Bernardi
On Wed, Jul 24, 2013 at 5:28 PM, Ben Duan wrote: > I have a question here. `esc' is used as the Meta key for key bindings in > Windows, for example key `esc;c:k' for `M-C-k'. Why not use `Alt' key > instead? Is it because Windows captured these keys? In the default configuration, the Alt key is

Re: [racket] Modules and File Save Bug?

2013-06-22 Thread Pierpaolo Bernardi
Looks like Sean wishes, like I do, that DrRacket would warn about buffers and files not being in sync. I submitted a PR about this: http://bugs.racket-lang.org/query/?cmd=view&pr=12810 Now we are two, that's a start! ;^) On Sat, Jun 22, 2013 at 9:40 PM, Robby Findler wrote: > The requires d

Re: [racket] A problem with Windows 8?

2013-05-26 Thread Pierpaolo Bernardi
I don't see how your function count-times implements the required algorithm. Please explain. On Mon, May 27, 2013 at 12:01 AM, Tomás Coiro wrote: > I'm trying to do this Rosetta Code problem: > http://rosettacode.org/wiki/Average_loop_length > > Now, this is my code > #lang racket > (require (o

Re: [racket] making a windows exe file

2013-05-10 Thread Pierpaolo Bernardi
On Fri, May 10, 2013 at 7:25 PM, Kejia柯嘉 wrote: > hi, > > i build my racket program to win7 execution file, but it needs some > dll on another win7 machine: cannot load dll libracket3m_8bh3lk.dll. > how can i build a standalone distribution program include all > dependencies for my case? You must

Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
On Fri, Apr 26, 2013 at 4:19 AM, Robby Findler wrote: > You wouldn't happen to have a citation for this traditional way, would you? > No. But I'll take note if I happen to remember some place where it is explained in this way. Racket Users list: http://lists.racket-lang.

Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
Ah, yes, right. On Fri, Apr 26, 2013 at 4:09 AM, Robby Findler wrote: > Yes, except that we do know something about what happens when it returns > #t in the "in all other cases" case. > > Robby > > > On Thu, Apr 25, 2013 at 9:03 PM, Pierpaolo Bernardi >

Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
The traditional way of explaining eq? is that it works when one of the arguments is a symbol or a mutable data structure. In all other cases the result is implementation dependent. Is this explanation still valid for racket? On Fri, Apr 26, 2013 at 1:37 AM, Robby Findler wrote: > I don't thin

Re: [racket] the extra empty string

2013-04-19 Thread Pierpaolo Bernardi
Or, maybe, what he's after is (for-each display '("" "0" "" "0")) ? (just guessing) Cheers P. On Sat, Apr 20, 2013 at 2:56 AM, Danny Yoo wrote: > On Fri, Apr 19, 2013 at 6:47 PM, Kejia柯嘉 wrote: > > Hi Yoo, > > > > You may try (display '("" "0" "" "0")), and you will find two whitepaces > >

Re: [racket] Visualizing Racket development

2013-04-12 Thread Pierpaolo Bernardi
Cool! On Fri, Apr 12, 2013 at 6:00 AM, Asumu Takikawa wrote: > Hi all, > > I just found out about this neat version control visualization tool > called "gource"[1] that creates animations of your git repo. I tried > using it on the Racket repo from the last few weeks. Here is the result: > >

Re: [racket] Math - factorial.rkt, binomial.rkt and memoization

2013-04-09 Thread Pierpaolo Bernardi
On Tue, Apr 9, 2013 at 3:30 PM, Pierpaolo Bernardi wrote: while the for version should be almost all big x big. > oops, no. The for version should be almost all fix x big. Here's a count considering also the type of the result of the multiplication: > (fact 100) #hash(((fix

Re: [racket] Math - factorial.rkt, binomial.rkt and memoization

2013-04-09 Thread Pierpaolo Bernardi
On Tue, Apr 9, 2013 at 2:51 PM, Laurent wrote: > On Tue, Apr 9, 2013 at 2:42 PM, Matthew Flatt wrote: > >> (for/product ([p (in-range (+ m 1) (+ n 1))]) p) > > > > But I don't fully understand why a simple (for/product ([p (in-range 1 > (add1 n))]) p) is as fast as the iota variants. > I don't

Re: [racket] Math - factorial.rkt, binomial.rkt and memoization

2013-04-09 Thread Pierpaolo Bernardi
On Tue, Apr 9, 2013 at 2:02 PM, Laurent wrote: > But if you write all 10 cases, aren't the lists constructed anyway before > calling `*'? > I'll leave the answer to someone who knows exactly how the compiler works. Intuitively, I thought my case should be better, but measuring them gives no app

Re: [racket] Math - factorial.rkt, binomial.rkt and memoization

2013-04-09 Thread Pierpaolo Bernardi
to)) (define (fact n) (if (zero? n) 1 (mult 2 (add1 n On Tue, Apr 9, 2013 at 1:43 PM, Pierpaolo Bernardi wrote: > But why generate lists which are immediately discarded? > > ;; from excluded; to included > (define (mult from to) > (case (- to from) >

Re: [racket] Math - factorial.rkt, binomial.rkt and memoization

2013-04-09 Thread Pierpaolo Bernardi
But why generate lists which are immediately discarded? ;; from excluded; to included (define (mult from to) (case (- to from) ((0) 1) ((1) to) ((2) (* (- to 1) to)) ((3) (* (- to 2) (- to 1) to)) ;; ... (else (let ((middle (quotient (+ from to) 2))) (* (mult

Re: [racket] current-output encoding

2013-04-04 Thread Pierpaolo Bernardi
On Mon, Apr 1, 2013 at 12:31 AM, Matthew Flatt wrote: > At Tue, 26 Mar 2013 18:29:00 +0100, Pierpaolo Bernardi wrote: > > On Tue, Mar 26, 2013 at 5:25 PM, Pierpaolo Bernardi > wrote: > > > On Tue, Mar 26, 2013 at 5:00 PM, Matthew Flatt > wrote: > > > > &g

Re: [racket] for/hash and for/list: adding nothing, adding more than one thing

2013-03-26 Thread Pierpaolo Bernardi
On Wed, Mar 27, 2013 at 4:46 AM, J. Ian Johnson wrote: > I can't really test what you've posted (no stress-testing code), and you also > compare safe versus unsafe accessors, which skews things. It was not meant to be testable code, just an example to frame the specific case I was talking about.

Re: [racket] current-output encoding

2013-03-26 Thread Pierpaolo Bernardi
On Tue, Mar 26, 2013 at 5:25 PM, Pierpaolo Bernardi wrote: > On Tue, Mar 26, 2013 at 5:00 PM, Matthew Flatt wrote: > >> I think you want `reencode-output-port', probably using "" (which >> represents the user's default encoding) as the target encoding. >

Re: [racket] current-output encoding

2013-03-26 Thread Pierpaolo Bernardi
On Tue, Mar 26, 2013 at 5:00 PM, Matthew Flatt wrote: > I think you want `reencode-output-port', probably using "" (which > represents the user's default encoding) as the target encoding. I tried the following: #lang racket (current-output-port (reencode-output-port (current-output-port)

Re: [racket] current-output encoding

2013-03-26 Thread Pierpaolo Bernardi
On Tue, Mar 26, 2013 at 4:42 PM, Michael Wilber wrote: > Does this do what you want? > >> (display (string->bytes/latin-1 "à")) > à This does not work when run from inside DrRacket. > See also: http://docs.racket-lang.org/reference/encodings.html?q=locale Ooops. I had looked only at the Guide,

[racket] current-output encoding

2013-03-26 Thread Pierpaolo Bernardi
Hello, suppose I have this program: #lang racket (display "à") This works as intended when run from DrRacket, but it displays mojibake if I generate an executable and run it from a console (on windows). How do I tell Racket what encoding to use for current-output? Cheers P. ___

Re: [racket] for/hash and for/list: adding nothing, adding more than one thing

2013-03-25 Thread Pierpaolo Bernardi
On Mon, Mar 25, 2013 at 2:41 PM, J. Ian Johnson wrote: > Let me know how you like my library. I'm thinking of adding some more > ergonomics to it: > 1) support right folds so a for/list-like comprehension has better allocation > behavior. > 2) add a keyword for-clause for starting an inner itera

Re: [racket] for/hash and for/list: adding nothing, adding more than one thing

2013-03-22 Thread Pierpaolo Bernardi
On Thu, Mar 21, 2013 at 11:55 PM, Tim Nelson wrote: > Dear All, > > I've recently started hacking Racket again, and am loving the for/* > constructs. > Awesome stuff. However, I have two questions about for/hash. > > (1) How can I *not* add a hash entry for a given iteration? > > When I use for/li

Re: [racket] Formatting reals

2013-03-12 Thread Pierpaolo Bernardi
On Wed, Mar 13, 2013 at 4:29 AM, Stephen Chang wrote: > Does real->decimal-string do what you want? yes, except for the width. It can substitute the ~r in (~a (~r (- pi) #:precision 6) #:width 12 #:align 'right) but not the ~a. Srfi/48 still wins in convenience and readability. 8^) Cheers

[racket] Formatting reals

2013-03-12 Thread Pierpaolo Bernardi
Hello, suppose I want to format a real number, with a fixed number of digits after the comma, rigth-padded in a given width, and I want the sign to be attached to the digits (i.e. not what ~r does). This is the usual way of printing reals in a table, and can be done trivially using standard funct

Re: [racket] providing cstructs

2013-03-09 Thread Pierpaolo Bernardi
On Sat, Mar 9, 2013 at 6:22 PM, Neil Toronto wrote: > I think you could also define the cstruct in a submodule, provide it using > `all-defined-out', and re-provide it from the enclosing module using > `all-from-out'. Ah, yes, that would have been another possibility. Thanks. __

Re: [racket] providing cstructs

2013-03-09 Thread Pierpaolo Bernardi
On Sat, Mar 9, 2013 at 9:32 AM, Tobias Hammer wrote: > (struct-out id), not _id still works. Only the 'special' names like _id, > _id-pointer etc. are not included. Exactly what I needed, thanks! You have spared me a weekend of typing. 8^) Racket Users list: http://list

[racket] providing cstructs

2013-03-09 Thread Pierpaolo Bernardi
Hello, I understand that there isn't an abbreviation equivalent to (provide (struct-out ...)), but for cstructs? Is this correct? (I have a cstrut with 62 fields to provide. Both readers and setters... 8^) P. Racket Users list: http://lists.racket-lang.org/users

Re: [racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 7:05 PM, Robby Findler wrote: > It wasn't a specific plan: DrRacket just tries to make creating an > executable behave like Run. > > But Pierpaolo: if you're regularly creating executables using this method, > maybe you'd rather script this process (and then, in the script,

Re: [racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 6:23 PM, Michael Wilber wrote: > Why not have a `run.rkt` that does something like > > #lang racket > (require "main.rkt") > (main) > > than you tell your users to run, and then just develop main.rkt inside > DrRacket? That's one possibility. However, having a separate f

Re: [racket] math/matrix <--> FFI/array

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 6:51 PM, Danny Yoo wrote: > On Wed, Feb 13, 2013 at 10:49 AM, Pierpaolo Bernardi > wrote: >> On Wed, Feb 13, 2013 at 6:14 PM, Danny Yoo wrote: >> >>> Other than that, this should work ok. Can you confirm? >> >> Yes, it works. Than

Re: [racket] math/matrix <--> FFI/array

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 6:14 PM, Danny Yoo wrote: > Other than that, this should work ok. Can you confirm? Yes, it works. Thanks! What's the difference between _byte and _int8 ? Racket Users list: http://lists.racket-lang.org/users

Re: [racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 6:29 PM, Sam Tobin-Hochstadt wrote: > You can change what submodules DrRacket executes when you press the > Run button. The setting for this is in the "Language" dialog. Sam, Danny, I can do this. And this solves half the problem: the main is not run from DrRacket. That'

Re: [racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 5:59 PM, Danny Yoo wrote: >> Is there a way for a program to know if it's running from inside DrRacket or >> from the command line? >> >> I would like to run a main function when from command line, and don't run it >> when in DrRacket. > > Yes; you can look at Test and Main

Re: [racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
On Wed, Feb 13, 2013 at 5:53 PM, Robby Findler wrote: > You can use submodules to do that. Tell the racket command-line to run the > submodule and drracket won't run it (drracket does run the 'main' submodule > by default, tho, so either use a different name or tell it not to do that). hmmm... so

[racket] Checking whether running from DrRacket.

2013-02-13 Thread Pierpaolo Bernardi
Hello, Is there a way for a program to know if it's running from inside DrRacket or from the command line? I would like to run a main function when from command line, and don't run it when in DrRacket. Thanks! P. Racket Users list: http://lists.racket-lang.org/users

Re: [racket] math/matrix <--> FFI/array

2013-02-13 Thread Pierpaolo Bernardi
Another FFI question: I want to interface a C function which has the following signature: void iauA2tf(int ndp, double angle, char *sign, int ihmsf[4]) The "char *sign" parameter is a single char, not a string, output only, and is giving me problems. The C code uses this parameter simply: *

Re: [racket] racket/db: fetching multiple rows with multiple columns in a "for" loop

2013-02-05 Thread Pierpaolo Bernardi
On Tue, Feb 5, 2013 at 5:57 PM, Dmitry Pavlov wrote: > Any hints will be much appreciated. Does the following help? (define (function-which-returns-an-unknown-number-of-values) (apply values (make-list (random 10) 'foo))) > (call-with-values function-which-returns-an-unknown-number-of-values

Re: [racket] phases

2013-01-29 Thread Pierpaolo Bernardi
On Tuesday, January 29, 2013, Danny Yoo wrote: By the way, you can probably use (system-type 'so-suffix)) > > you'll probably want to use a define-runtime-path Thanks! I'll certainly put this to use. Cheers P. Racket Users list: http://lists.racket-lang.org/users

Re: [racket] phases

2013-01-29 Thread Pierpaolo Bernardi
On Tuesday, January 29, 2013, Matthew Flatt wrote: > At Tue, 29 Jan 2013 19:18:13 +0100, Pierpaolo Bernardi wrote: > > Here's one way to do that: > > (module sofa-params racket/base This worked. Thanks! P. Racket Users list: http://lists.racket-lang.org/users

[racket] phases

2013-01-29 Thread Pierpaolo Bernardi
Hello, what's the incantation needed to make the following work: #lang racket (provide sofa-version) (require ffi/unsafe) (require ffi/unsafe/define) (require racket/runtime-path) (define sofa-version "20120301_a") (define arch (if (fixnum? #e10e15) 'x64 'x86)) ;; Access a file "d

[racket] math/matrix <--> FFI/array

2013-01-21 Thread Pierpaolo Bernardi
Hello, what's the most convenient way to convert between math/matrices and FFI/arrays? To reduce the scope of the question, at the moment I'm only interested in conversions from and to the following FFI types: (_array _double 3 3) (_array _double 3) (_array _double 2 3) Thanks! P. __

Re: [racket] Fun with the FFI

2013-01-09 Thread Pierpaolo Bernardi
It works. Thanks! 2013/1/9, Ryan Culpepper : > On 01/09/2013 05:16 PM, Pierpaolo Bernardi wrote: >> Hello all, >> >> Can someone show me what's the correct FFI type for this C function: >> >> int foo(double a, double b, double *c, double *d) >> >&g

[racket] Fun with the FFI

2013-01-09 Thread Pierpaolo Bernardi
Hello all, Can someone show me what's the correct FFI type for this C function: int foo(double a, double b, double *c, double *d) where c and d are output only parameters, and I want back *c, *d, and the int return value. Thanks! Racket Users list: http://lists.racket-l

Re: [racket] Math library ready for testing

2012-12-17 Thread Pierpaolo Bernardi
On Mon, Dec 17, 2012 at 1:55 PM, Jens Axel Søgaard wrote: >> >> moebius-mu > Would it be enough to add "distinct" ? IMO, yes. >> >> multinomial >> >> "(multinomial n ks) → Natural >>n : Integer >> ks : (Listof Integer) >> ... >>> (multinomial 5 3 2) >> 10" >> >> The example doe

Re: [racket] Math library ready for testing

2012-12-17 Thread Pierpaolo Bernardi
Some comments after scanning the manual. flulp-error "For non-rational arguments such as +nan.0, flulp-error returns 0.0 if (eqv? x r); otherwise it returns +inf.0." However one example is: > (flulp-error +inf.0 +nan.0) +nan.0 Which does not agree with the doc. "2.3.2 Flonum Constan

Re: [racket] Math library ready for testing

2012-12-12 Thread Pierpaolo Bernardi
ocs. > > Neil ⊥ > > > On 12/12/2012 08:16 AM, Robby Findler wrote: >> >> But it could be elided for the docs. >> >> Robby >> >> On Wed, Dec 12, 2012 at 8:33 AM, J. Ian Johnson wrote: >>> >>> I imagine that's there more for Typed

Re: [racket] Math library ready for testing

2012-12-12 Thread Pierpaolo Bernardi
On Fri, Dec 7, 2012 at 9:33 PM, Neil Toronto wrote: > I've just pushed the last commits that make the new math library ready for > wider testing. Almost everything ready for use is documented, the tests keep > passing, and everything *seems* to work. (max-math-threads) → Positive-Integer

Re: [racket] deceptive perfomance for typed racket in integer division

2012-12-12 Thread Pierpaolo Bernardi
On Tue, Dec 11, 2012 at 7:09 PM, Neil Toronto wrote: > I've had good success running DrRacket and selecting "No debugging or > profiling" and deselecting "Preserve stacktrace" in the Language dialog. > Most of the time, I get performance similar to command-line Racket. I think > the only signific

Re: [racket] Math library ready for testing

2012-12-12 Thread Pierpaolo Bernardi
BTW, I seem to remember that GMP stores the table of small primes as a vector of the differences between consecutive primes. Storing a byte per prime goes a long way. Let's see... there are 50847534 primes under 10^9, the max difference between a consecutive pair of them is 282. We can store that

Re: [racket] Math library ready for testing

2012-12-11 Thread Pierpaolo Bernardi
On Tue, Dec 11, 2012 at 5:11 PM, Stephen Bloch wrote: > How many primes are below ten million? A hundred million? At some point > storing the primes will take less memory than storing primality flags, but > that point may be above the size of tables we can realistically store today. > (for

Re: [racket] deceptive perfomance for typed racket in integer division

2012-12-11 Thread Pierpaolo Bernardi
On Tue, Dec 11, 2012 at 5:28 PM, Sam Tobin-Hochstadt wrote: >> This looks like you are testing from inside DrRacket. As I already >> wrote you should generate an executable and measure that. >> >> If you run the test from inside DrRacket, you are measuring DrRacket >> overhead, which is far from

Re: [racket] deceptive perfomance for typed racket in integer division

2012-12-11 Thread Pierpaolo Bernardi
On Tue, Dec 11, 2012 at 5:23 PM, Pierpaolo Bernardi wrote: > If you run the test from inside DrRacket, you are measuring DrRacket > overhead, which is far from negligible. As an example, the test I just sent, with the limit changed to 60999, on my machine runs in 20083 ms from inside Dr

  1   2   >