unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Aubrey Jaffer <agj-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
To: Dan Gildea <gildea-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
Cc: slib-discuss-mXXj517/zsQ@public.gmane.org,
	guile-devel-mXXj517/zsQ@public.gmane.org
Subject: Re: slib primes
Date: Thu, 16 Apr 2009 22:29:18 -0400 (EDT)	[thread overview]
Message-ID: <20090417022918.D9C4651D7E7@voluntocracy.org> (raw)
In-Reply-To: <20090416224432.GA9551-U9BOa8JvqEg/A7J+Bw32uJkQkdDMV+C2@public.gmane.org> (message from	Dan Gildea on Thu, 16 Apr 2009 18:44:32 -0400)

 | Date: Thu, 16 Apr 2009 18:44:32 -0400
 | From: Dan Gildea <gildea-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
 | 
 | On Thu, April 16, 2009 at 12:07PM, Aubrey Jaffer wrote:
 | >  | Date: Wed, 15 Apr 2009 20:33:53 -0400
 | >  | From: Dan Gildea <gildea-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
 | >  | 
 | >  | bash-3.2$ guile-1.8
 | >  | guile> (version)
 | >  | "1.8.6"
 | >  | guile> (use-modules (ice-9 slib))
 | >  | guile> *slib-version*
 | >  | "3b1"
 | >  | guile> (require 'primes)
 | >  | ERROR: Wrong number of arguments to #<primitive-procedure list->array>

Use-modules doesn't work on my development machine; but that's not
your problem.  The list->array issue was addressed last year, but I
haven't made a release since then.  The following message includes a
patch to fix the problem.

------- Start of forwarded message -------
From: Aubrey Jaffer <agj-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
In-reply-to: <87od8jjeil.fsf-mXXj517/zsQ@public.gmane.org> (ludo-mXXj517/zsQ@public.gmane.org)
Date: Wed,  9 Apr 2008 20:14:05 -0400 (EDT)

 | From: ludo-mXXj517/zsQ@public.gmane.org (Ludovic =?iso-8859-1?Q?Court=E8s?=)
 | Date: Wed, 09 Apr 2008 16:20:50 +0200
 | 
 | SLIB's `array' module (and possibly others) from SLIB 3b1 appears
 | to be partly inaccessible from Guile 1.8 as reported here:
 | 
 |   http://permalink.gmane.org/gmane.lisp.guile.user/6527
 | 
 | Any idea what to look for?

  In /home/ludo/soft/lib/slib/byte.scm:
    61: 6  [list->array 1 #u32(32) (0 0 1 1 0 1 0 1 0 ...)]

  /home/ludo/soft/lib/slib/byte.scm:61:3: In procedure list->array in expression (list->array 1 (A:fixN8b) ...):
  /home/ludo/soft/lib/slib/byte.scm:61:3: Wrong number of arguments to #<primitive-procedure list->array>

Guile-1.8.1's list->array takes two arguments; but it should take
three (see http://srfi.schemers.org/srfi-63/srfi-63.html or
http://swiss.csail.mit.edu/~jaffer/slib_7.html#SEC193 )

  guile> (array->list (list->array 2 '((0 1) (1 4))))
  ((0 1) (1 4))

  guile> (array->list (list->array 2 '#() '((0 1) (1 4))))

  Backtrace:
  In standard input:
     8: 0* [array->list ...
     8: 1*  [list->array 2 #() ((0 1) (1 4))]

  standard input:8:14: In procedure list->array in expression (list->array 2 (begin #) ...):
  standard input:8:14: Wrong number of arguments to #<primitive-procedure list->array>
  ABORT: (wrong-number-of-args)

Appended is a patch which corrects list->array, as well as providing
missing array->vector and vector->array.

Thanks for your bug report.  The development version is updated:
http://groups.csail.mit.edu/mac/ftpdir/users/jaffer/slib.zip

Also, the CVS repository is updated:
https://savannah.gnu.org/cvs/?group=slib

 | Thanks,
 | Ludovic.
 ...
 | _______________________________________________
 | Slib-discuss mailing list
 | Slib-discuss-mXXj517/zsQ@public.gmane.org
 | http://lists.gnu.org/mailman/listinfo/slib-discuss

Index: guile.init
===================================================================
RCS file: /cvsroot/slib/slib/guile.init,v
retrieving revision 1.69
retrieving revision 1.70
diff -c -r1.69 -r1.70
*** guile.init	25 Feb 2008 20:59:56 -0000	1.69
- --- guile.init	9 Apr 2008 23:23:55 -0000	1.70
***************
*** 559,564 ****
- --- 559,620 ----
  (if (string>=? (scheme-implementation-version) "1.8")
      (module-replace! (current-module) '(make-array)))
  
+ (cond
+  ((string<=? (scheme-implementation-version) "1.8.1")
+ (define (list->array rank proto lst)
+   (define dimensions
+     (do ((shp '() (cons (length row) shp))
+ 	 (row lst (car lst))
+ 	 (rnk (+ -1 rank) (+ -1 rnk)))
+ 	((negative? rnk) (reverse shp))))
+   (let ((nra (apply make-array proto dimensions)))
+     (define (l2ra dims idxs row)
+       (cond ((null? dims)
+ 	     (apply array-set! nra row (reverse idxs)))
+ 	    ((if (not (eqv? (car dims) (length row)))
+ 		 (slib:error 'list->array
+ 			     'non-rectangular 'array dims dimensions))
+ 	     (do ((idx 0 (+ 1 idx))
+ 		  (row row (cdr row)))
+ 		 ((>= idx (car dims)))
+ 	       (l2ra (cdr dims) (cons idx idxs) (car row))))))
+     (l2ra dimensions '() lst)
+     nra))
+ ))
+ 
+ (cond
+  ((not (defined? 'vector->array))
+ (define (vector->array vect prototype . dimensions)
+   (define vdx (vector-length vect))
+   (if (not (eqv? vdx (apply * dimensions)))
+       (slib:error 'vector->array vdx '<> (cons '* dimensions)))
+   (let ((ra (apply make-array prototype dimensions)))
+     (define (v2ra dims idxs)
+       (cond ((null? dims)
+ 	     (set! vdx (+ -1 vdx))
+ 	     (apply array-set! ra (vector-ref vect vdx) (reverse idxs)))
+ 	    (else
+ 	     (do ((idx (+ -1 (car dims)) (+ -1 idx)))
+ 		 ((negative? idx) vect)
+ 	       (v2ra (cdr dims) (cons idx idxs))))))
+     (v2ra dimensions '())
+     ra))
+ (define (array->vector ra)
+   (define dims (array-dimensions ra))
+   (let* ((vdx (apply * dims))
+ 	 (vect (make-vector vdx)))
+     (define (ra2v dims idxs)
+       (if (null? dims)
+ 	  (let ((val (apply array-ref ra (reverse idxs))))
+ 	    (set! vdx (+ -1 vdx))
+ 	    (vector-set! vect vdx val))
+ 	  (do ((idx (+ -1 (car dims)) (+ -1 idx)))
+ 	      ((negative? idx) vect)
+ 	    (ra2v (cdr dims) (cons idx idxs)))))
+     (ra2v dims '())
+     vect))
+ ))
+ 
  (define create-array make-array)
  (define (make-uniform-wrapper prot)
    (if (string? prot) (set! prot (string->number prot)))


_______________________________________________
Slib-discuss mailing list
Slib-discuss-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/slib-discuss
------- End of forwarded message -------

      parent reply	other threads:[~2009-04-17  2:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16  0:33 slib primes Dan Gildea
     [not found] ` <20090416003353.GA22389-U9BOa8JvqEg/A7J+Bw32uJkQkdDMV+C2@public.gmane.org>
2009-04-16 16:07   ` Aubrey Jaffer
2009-04-16 22:23     ` Ludovic Courtès
     [not found]       ` <87y6u0kzk2.fsf-mXXj517/zsQ@public.gmane.org>
2009-04-16 22:44         ` Aubrey Jaffer
     [not found]           ` <20090416224421.B9EDC51D7E7-F8W5xzWImdI61HJwdXWPoQ@public.gmane.org>
2009-04-16 23:11             ` Ludovic Courtès
2009-04-16 22:44     ` [Slib-discuss] " Dan Gildea
     [not found]       ` <20090416224432.GA9551-U9BOa8JvqEg/A7J+Bw32uJkQkdDMV+C2@public.gmane.org>
2009-04-17  2:29         ` Aubrey Jaffer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090417022918.D9C4651D7E7@voluntocracy.org \
    --to=agj-frubxkncsvf2fbvcvol8/a@public.gmane.org \
    --cc=gildea-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org \
    --cc=guile-devel-mXXj517/zsQ@public.gmane.org \
    --cc=slib-discuss-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).