From: Bob Felts
Subject: Help with Lisp type system
Date: 
Message-ID: <1irh82g.oiqora1m525agN%wrf3@stablecross.com>
Given +foo+ and +bar+ (2 constants, value not really important here),
I'd like to make an unsigned-byte 8 sequence containing these two
values.  The brute force way:

  (let ((blob (make-array 2 :element-type '(unsigned-byte 8))))
    (setf (aref blob 0) +foo+)
    (setf (aref blob 1) +bar+)
    blob))

But surely I ought to be able to use :initial-contents to populate the
array.  I just haven't been able to find the right incantation that
makes everyone happy.

Any help appreciated.

From: Thomas M. Hermann
Subject: Re: Help with Lisp type system
Date: 
Message-ID: <b0943982-f929-49f3-b066-2e3f6e371adb@k19g2000yqg.googlegroups.com>
On Dec 5, 12:04 pm, ····@stablecross.com (Bob Felts) wrote:
> Given +foo+ and +bar+ (2 constants, value not really important here),
> I'd like to make an unsigned-byte 8 sequence containing these two
> values.  The brute force way:
>
>   (let ((blob (make-array 2 :element-type '(unsigned-byte 8))))
>     (setf (aref blob 0) +foo+)
>     (setf (aref blob 1) +bar+)
>     blob))
>
> But surely I ought to be able to use :initial-contents to populate the
> array.  I just haven't been able to find the right incantation that
> makes everyone happy.
>
> Any help appreciated.

Not sure how you are specifying the initial-contents, but this worked
for me:

(make-array 2 :element-type '(unsigned-byte 8) :initial-contents (list
+foo+ +bar+))

or

(make-array 2 :element-type '(unsigned-byte 8) :initial-contents
(vector +foo+ +bar+))

HTH,

Tom
From: Bob Felts
Subject: Re: Help with Lisp type system
Date: 
Message-ID: <1irh9en.1u2w4ds1vg83boN%wrf3@stablecross.com>
Thomas M. Hermann <··········@gmail.com> wrote:

> On Dec 5, 12:04 pm, ····@stablecross.com (Bob Felts) wrote:
> > Given +foo+ and +bar+ (2 constants, value not really important here),
> > I'd like to make an unsigned-byte 8 sequence containing these two
> > values.  The brute force way:
> >
> >   (let ((blob (make-array 2 :element-type '(unsigned-byte 8))))
> >     (setf (aref blob 0) +foo+)
> >     (setf (aref blob 1) +bar+)
> >     blob))
> >
> > But surely I ought to be able to use :initial-contents to populate the
> > array.  I just haven't been able to find the right incantation that
> > makes everyone happy.
> >
> > Any help appreciated.
> 
> Not sure how you are specifying the initial-contents, but this worked
> for me:
> 
> (make-array 2 :element-type '(unsigned-byte 8) :initial-contents (list
> +foo+ +bar+))
> 
> or
> 
> (make-array 2 :element-type '(unsigned-byte 8) :initial-contents
> (vector +foo+ +bar+))
> 

I could have sworn I tried that.  Thanks for the help.
From: Alberto Riva
Subject: Re: Help with Lisp type system
Date: 
Message-ID: <ghbrq3$gc3m$1@usenet.osg.ufl.edu>
Bob Felts wrote on 12/05/2008 01:04 PM:
> Given +foo+ and +bar+ (2 constants, value not really important here),
> I'd like to make an unsigned-byte 8 sequence containing these two
> values.  The brute force way:
> 
>   (let ((blob (make-array 2 :element-type '(unsigned-byte 8))))
>     (setf (aref blob 0) +foo+)
>     (setf (aref blob 1) +bar+)
>     blob))
> 
> But surely I ought to be able to use :initial-contents to populate the
> array.  I just haven't been able to find the right incantation that
> makes everyone happy.

What about:

(let ((blob (make-array 2 :element-type '(unsigned-byte 8)
                           :initial-contents (list +foo+ +bar+))))
   blob)

?

Alberto