Re: [racket] Offtopic: Favorite resources for mastering SML?

2013-07-04 Thread Phil Bewig
Sorry, I meant this for the list, not just Grant. After I wrote it, I looked again at my bookshelf and found *Elements of Functional Programming* by Chris Reade, which reminds me in a small way of SICP. It belongs in the intermediate/advanced category. On Thu, Jul 4, 2013 at 10:04 AM, Phil

Re: [racket] Math library ready for testing

2012-12-11 Thread Phil Bewig
with nth-prime > > > On Tue, Dec 11, 2012 at 8:31 AM, Phil Bewig wrote: > >> There must be an error in the prime-counting function. According to > href=" >> http://www.wolframalpha.com/input/?i=how+many+primes+less+than+a+million";>Wolfram|Alpha, >>

Re: [racket] Math library ready for testing

2012-12-11 Thread Phil Bewig
There must be an error in the prime-counting function. According to http://www.wolframalpha.com/input/?i=how+many+primes+less+than+a+million";>Wolfram|Alpha, there are 79486 primes less than a million, not 78497. I don't use Racket, but I do have lots of Scheme code that computes with prime number

Re: [racket] Making a Racket function "recallable"

2012-02-15 Thread Phil Bewig
You might be interested in SRFI-41 . One of the examples is an infinite stream of fibonacci numbers. On Wed, Feb 15, 2012 at 1:50 PM, Joe Gilray wrote: > Danny is correct... ouch (/.\ <- covering my head in shame). > > Anyway to close the chapter on this, below

Re: [racket] Porter stemming algorithm

2012-02-08 Thread Phil Bewig
If you're looking at the suggested solution, the easiest way to get the code is to follow the links to the codepad page and copy the code from there. If you're looking at the program in the comments, you may want to view source and scroll down to the program. You'll have to delete the html tags an

Re: [racket] Porter stemming algorithm

2012-02-05 Thread Phil Bewig
There are two stemmers on that page. I wrote the reference solution, but not the solution given in the comments. If it is the reference solution that is causing trouble, I am happy to help. Please tell me exactly what is going wrong. On Sun, Feb 5, 2012 at 2:42 AM, John Sampson wrote: > Hello -

Re: [racket] Bloom filter?

2011-06-06 Thread Phil Bewig
ser passphrases > against a *gigantic* dictionary of known ones. > > Best, > > Erich > > > On Mon, 2011-06-06 at 09:56 -0500, Phil Bewig wrote: > > I implemented a spell checker using a Bloom filter > > at http://programmingpraxis.com/2009/04/21/probabilistic-spell

Re: [racket] Bloom filter?

2011-06-06 Thread Phil Bewig
I implemented a spell checker using a Bloom filter at http://programmingpraxis.com/2009/04/21/probabilistic-spell-checking/. On Mon, Jun 6, 2011 at 9:48 AM, Erich Rast wrote: > Hi, > > I need to check whether a given string already occurs in a list of > several million strings, where occasional

Re: [racket] newbie string handling problem

2011-03-31 Thread Phil Bewig
; lnic -- last non-white is colon (define (lnic? s) ; explode to list (let loop ((cs (reverse (string->list s (cond ((null? cs) #f) ((char-whitespace? (car cs)) (loop (cdr cs))) (else (char=? (car cs) #\:) (define (lnic? s) ; index into string (let loop ((i (-

Re: [racket] stream-cons from racket/stream isn't lazy

2011-03-05 Thread Phil Bewig
You should use SRFI-41, as SRFI-40 is deprecated. On Sat, Mar 5, 2011 at 6:31 PM, Mark Engelberg wrote: > I've had some email discussions about this with the Racket team in the > past, so here's a quick unofficial summary of what I've learned, while > you're waiting for a more official response:

Re: [racket] Is there anything like the cl format?

2010-12-17 Thread Phil Bewig
SLIB (http://people.csail.mit.edu/jaffer/SLIB.html) has format in all its CL glory. On Fri, Dec 17, 2010 at 3:01 PM, Jos Koot wrote: > Because of pressing the wrong send button, my repsonse was not transmitted > to the Racket list. Sorry. > In the meantime I agree with you to use the tools that

Re: [racket] a small programming exercise

2010-10-15 Thread Phil Bewig
Not quite. Random numbers are uniformly distributed, so the first digits of a set of random numbers should all appear equally. Benford's Law most often applies to sets of naturally-occurring numbers that are scale-invariant. Consider the lengths of rivers, as Benford did. It doesn't matter whet

Re: [racket] a small programming exercise

2010-10-14 Thread Phil Bewig
This works, assuming xs consists of positive integers: (define (benford xs) (for-each (lambda (x) (printf "~a ~f~%" (car x) (/ (cdr x) (length xs (uniq-c = (sort < (map (compose car digits) xs) Compose, digits and uniq-c are from my Standard Prelude

Re: [racket] [BULK] Re: Looking for feedback on code style

2010-09-13 Thread Phil Bewig
Horn wrote: > On 9/13/10 2:46 PM, Stephen Bloch wrote: > >> On Sep 13, 2010, at 1:34 PM, Phil Bewig wrote: >> >> Do you know a better way to shuffle a list than to convert it to a >>> vector, shuffle in place, then convert back to a list? You might look >

Re: [racket] Looking for feedback on code style

2010-09-13 Thread Phil Bewig
Fixed. See the comment at http://programmingpraxis.com/2009/12/11/selection/. Prabhakar: You are correct that shuffling once at the beginning is sufficient. But I am interested in your critique of shuffling. Do you know a better way to shuffle a list than to convert it to a vector, shuffle in

Re: [racket] Looking for feedback on code style

2010-09-09 Thread Phil Bewig
:33 AM, Phil Bewig wrote: > >> http://programmingpraxis.com/2009/12/11/selection/ >> > > This method takes O(n) time with high probability if the partitioning > element is chosen deterministically and the data is randomly permuted (with > all permutations equally likely)

Re: [racket] Looking for feedback on code style

2010-09-09 Thread Phil Bewig
http://programmingpraxis.com/2009/12/11/selection/ On Thu, Sep 9, 2010 at 10:26 AM, David Van Horn wrote: > On 9/9/10 10:04 AM, Prabhakar Ragde wrote: > >> I don't think vectors help very much in this case (median-finding). For >> the given code, the O(n) access to the middle of the list is domin