# How to make a list with one element to a number

Hi everyone. Here is a rudimentary question.

I would like to do:

(N) [list] into N [number]

Vell actually remove the parenthesis.

I’m really twisting my brain.

Dear Dagfinn,

Can you give a concrete example?
Maybe you wish to do this (?): (1 2 3 4) → 1234 ???
Best
K

1 Like

Dear Karim, yes I can. And thanks to you asking me for an example, it looks like I’ve [hopefully] solved the problem. But that doesn’t mean that the solution can not be more elegant.

Best Dagfinn
Example list to number.omp (13.0 KB)

1 Like

Something went wrong with the .omp file.
Example list to number.omp (13.6 KB)

1 Like

Yes indeed!

1 Like

Dear Karim, here is an operating version. See inside the patch for comments on CDR and BUTLAST.

Best, Dagfinn

Dear Dagfinn,

Thanx. Just a precision about cdr: cdr returns the rest of a list, of course meaning taking out the car of the list which happens to be the first element. This definition is better because cdr goes with car. car being the head of a list. These two functions are the base of lisp language.

In computer programming, CAR (`car`) /kɑːr/ (listen) and CDR (`cdr`) (/ˈkʌdər/ (listen) or /ˈkʊdər/ (listen)) are primitive operations on cons cells (or “non-atomic S-expressions”) introduced in the Lisp programming language. A cons cell is composed of two pointers; the car operation extracts the first pointer, and the cdr operation extracts the second.

Thus, the expression `(car (cons x y))` evaluates to `x`, and `(cdr (cons x y))` evaluates to `y`.

When cons cells are used to implement singly linked lists (rather than trees and other more complicated structures), the car operation returns the first element of the list, while cdr returns the rest of the list. For this reason, the operations are sometimes given the names first and rest or head and tail.

from:

Best
K

2 Likes

Dear Karim, thanks a lot. When learning at first Patch Work and then Open Music, I should have studied the basics of LISP. I went along studying alone. I have “The Little Lisper” though. So the lack of basics is a tail that I’m dragging along since 1997. Best, Dagfinn

1 Like

Dear Dagfinn,

These are just details. After all what’s important is music no?

Best my friend
K

1 Like