How to merge two list and split them from the list by using car cdr only?

in clisp,
I woud like to use two lists and get the output below
1.(a b c)
2.(A B C)

output. ((a A)(b B)(c C))

I see how to make a combined list by using merge but not for spliting them like the output.
jiwonmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Are you not allowed to use "cons" ?
0
käµfm³d 👽Commented:
While I await your response, I propose the following:
(let (y (a b c))
     (z (A B C)))
(let* (a (cons (car y) (car z)))
      (b (cons (car (cdr y)) (car (cdr z))))
      (c (cons (car (cdr (cdr y))) (car (cdr (cdr z))))))
(cons a b c)

Open in new window

0
käµfm³d 👽Commented:
Actually, while playing around with it more, I realize that the code above probably won't even compile. The following was tested in a Scheme interpreter so I won't swear by it, but I believe it should be compatible with Lisp (since Scheme is a Lisp dialect). This seemed to give the result you were searching for.
(let ((y '("a" "b" "c"))
      (z '("A" "B" "C"))
     )
     (let* ((a (list (car y) (car z)))
            (b (list (car (cdr y)) (car (cdr z))))
            (c (list (car (cdr (cdr y))) (car (cdr (cdr z)))))
           )
           (display (list a b c))))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

jiwonmanAuthor Commented:
I can use cons and merge. Sorry for the confusion.
this problem is trickier than I thought.
0
jiwonmanAuthor Commented:
I am running on clisp btw.
0
käµfm³d 👽Commented:
I don't see the merge function mentioned anywhere in Lisp documentation. Is this a custom function?
0
jiwonmanAuthor Commented:
>kaufmed, on the common lisp, yeah it's already built in.
for ex.
(merge 'string "abc" "ABC" #'char-lessp)

"aAbBcC"
0
jiwonmanAuthor Commented:
more examples on the screenshot. :)
merge-suritam9.jpg
0
jiwonmanAuthor Commented:
hmmm. try this link to open the picture, the pic above not opening for some reason.
http://postfiles9.naver.net/data20/2007/1/21/168/merge-suritam9.jpg?type=w2
0
fridomCEO/ProgrammerCommented:
(mapcar #'(lambda (a b) (cons a b)) (list "a" "b" "c") (list "A" "B" "C"))
(("a" . "A") ("b" . "B") ("c" . "C"))
CL-USER>

Regards
Friedrich
0
jiwonmanAuthor Commented:
I was looking at mapcar function, but I don't want to use that.
0
jiwonmanAuthor Commented:
your comment was helpful. Thank you. It seems like clisp is slightly different than the one you mentioned.
 It was really helpful! have a nice day, Kaufmed
0
käµfm³d 👽Commented:
Sure thing. Sorry it wasn't exact. I did not know how different Scheme and CLisp were.

So if I did help, then glad to do so  :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.