From: Jay
Subject: help me, pls
Date: 
Message-ID: <3821C5E4.E606EF41@hotmail.com>
Please help a lisp newbie.
I am trying to do the following
(setq my-list '( a b c))
then a becomes (a1 a2)
and b becomes (b1 b2)
then, my-list should look like
((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c))
Please show me how to do it in lisp.
Thanks a million!!!!
jason

From: Eugene Zaikonnikov
Subject: Re: help me, pls
Date: 
Message-ID: <3821D6EC.939D625F@cit.org.by>
Jay wrote:
> 
> Please help a lisp newbie.
> I am trying to do the following
> (setq my-list '( a b c))
> then a becomes (a1 a2)
> and b becomes (b1 b2)
> then, my-list should look like
> ((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c))
> Please show me how to do it in lisp.

(setq a '(a1 a2))
(setq b '(b1 b2))
(setq my-list '((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c)))
Kidding of course.

Could you formulate your problem in other way? What are you trying to
do? Is it something about matrixes?
The description above is not terribly self-explanatory.

--
  Eugene
  (concatenate 'string "viking" ·@" "cit.org.by")
From: Jay
Subject: Re: help me, pls
Date: 
Message-ID: <3821FEAB.A0A7DAD1@hotmail.com>
:-(
thanks.
Sorry for the ambiguity of my first post.
Here is what I am trying to do.

There is a list with arbitrary length, which looks like (A B C D)
Then, any element in the list could turn into a list with no more than
two elements in it, e.g, "A" could take a the form like (a1 a2) or A1.
 Given the new values of A B C and D, the list should look like something
like this:
((a1 B c1  D1)
 (a1 B c2 D1)
 (a2 B c1 D1)
 (a2 B c2 D1)).
here is function  I am working on::
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun make-new-lists (old-list, update-values)
;old-list is just like (A B C D) i said above
;update -values is like ((a1 a2) B (c1 c2) (D1) )
;( want to end up with a list like ((a1 B c1  D1) (a1 B c2 D1) (a2 B c1
D1) (a2 B c2 D1)), yes, a matrix.
    (let ((result-list nil))
       ;;;I wrote some codes here, which does not make sense even to
myself

result-list))
;;;;;;;;;;;;;;;;;;;;;;;;;
Would you pls show me how to do it?
I really needs your help.
Thank you very very much.

Eugene Zaikonnikov wrote:

> (setq a '(a1 a2))
> (setq b '(b1 b2))
> (setq my-list '((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c)))
> Kidding of course.
>
> Could you formulate your problem in other way? What are you trying to
> do? Is it something about matrixes?
> The description above is not terribly self-explanatory.
>
> --
>   Eugene
>   (concatenate 'string "viking" ·@" "cit.org.by")
From: Arseny Slobodjuck
Subject: Re: help me, pls
Date: 
Message-ID: <38228d30@news.vtc.ru>
Jay wrote in message <·················@hotmail.com>...

>There is a list with arbitrary length, which looks like (A B C D)
>Then, any element in the list could turn into a list with no more than
>two elements in it, e.g, "A" could take a the form like (a1 a2) or A1.
> Given the new values of A B C and D, the list should look like something
>like this:
>((a1 B c1  D1)
If line above is first element of original list (A B C D)  i.e. element A,
then why it contains of 4 subelements ?  Then, why do you use
capital and lowercase letters, maybe it means that a1 is a
'terminal' element, when B is a list ?

> (a1 B c2 D1)
> (a2 B c1 D1)
> (a2 B c2 D1)).
From: Eugene Zaikonnikov
Subject: Re: help me, pls
Date: 
Message-ID: <941813688.313974@lxms.cit.org.by>
Jay <······@hotmail.com> wrote in message
······················@hotmail.com...
[snip]
> here is function  I am working on::
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defun make-new-lists (old-list, update-values)
> ;old-list is just like (A B C D) i said above
> ;update -values is like ((a1 a2) B (c1 c2) (D1) )
> ;( want to end up with a list like ((a1 B c1  D1) (a1 B c2 D1) (a2 B c1
> D1) (a2 B c2 D1)), yes, a matrix.
>     (let ((result-list nil))
>        ;;;I wrote some codes here, which does not make sense even to
> myself

Wait, wait. Are you sure that B in update-values should be atomic? Why do
you need old-list? It has no relation with result-list, except it is also a
four-element list and it has atom B.
Ok, here is my cut, though it doesn't works with atomic list entries.
Massaging input properly should be easy. I didn't meditated over a recursive
solution that wouldn't (to . hell).

(defun make-new-lists (l)
  (destructuring-bind (sub1 sub2 sub3 sub4 &optional (result nil))
      l
    (loop for a1 in sub1
          do (loop for a2 in sub2
                   do (loop for a3 in sub3
                            do (loop for a4 in sub4
                                     do
                                     (setf result (cons (list a1 a2 a3 a4)
result))))))
    (nreverse result)))

CL-USER 3 > (make-new-lists '((a1 a2) (b) (c1 c2) (d1)))
((A1 B C1 D1) (A1 B C2 D1) (A2 B C1 D1) (A2 B C2 D1))

--
  Eugene
  (concatenate 'string "viking" ·@" "cit.org.by")
From: Josh Gardner
Subject: Re: help me, pls
Date: 
Message-ID: <3822198C.68FEE03F@openroad.ca>
This is a multi-part message in MIME format.
--------------28E06A3F7D943C503A9FD982
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hmm, this is a very vague problem spec.. could you try to state it more
conciesly? I'm sure you'll get more meaningful help that way.

Also: Have you thouhg of using mapcar, or mapcan? I'm sure you could use
this with a lambda to achieve your desired results.

Jay wrote:

> Please help a lisp newbie.
> I am trying to do the following
> (setq my-list '( a b c))
> then a becomes (a1 a2)
> and b becomes (b1 b2)
> then, my-list should look like
> ((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c))
> Please show me how to do it in lisp.
> Thanks a million!!!!
> jason

--------------28E06A3F7D943C503A9FD982
Content-Type: text/x-vcard; charset=us-ascii;
 name="jgard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Josh Gardner
Content-Disposition: attachment;
 filename="jgard.vcf"

begin:vcard 
n:Gardner;Josh
tel;fax:604.681.0916
tel;work:604.681.0516
x-mozilla-html:FALSE
org:OpenRoad Communications
adr:;;;;;;
version:2.1
···················@openroad.ca
title:UNIX Web Developer
fn:Josh Gardner
end:vcard

--------------28E06A3F7D943C503A9FD982--
From: Alex Henderson
Subject: Re: help me, pls
Date: 
Message-ID: <38236937.906D70F4@cam.ac.uk>
> Please help a lisp newbie.
> I am trying to do the following
> (setq my-list '( a b c))
> then a becomes (a1 a2)
> and b becomes (b1 b2)
> then, my-list should look like
> ((a1 b1 c) (a1 b2 c) (a2 b1 c) (a2 b2 c))
> Please show me how to do it in lisp.

Something like this?

---
(defun msubstitute (list &rest subs)
  (apply 'msubs-aux (list list) subs))

(defun msubs-aux (lists &rest subs)
  (if subs
    (let (newlists)
      (dolist (list lists (apply 'msubs-aux newlists (cdr subs)))
        (setf newlists
              (append newlists
                      (mapcar #'(lambda (r)
                                  (substitute r (caar subs) list))
                              (cadar subs))))))
    lists))
---

A