unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Array to list and vice versa
@ 2022-11-06 13:40 Heime
  2022-11-06 13:58 ` Emanuel Berg
  2022-11-06 14:25 ` Stephen Berman
  0 siblings, 2 replies; 4+ messages in thread
From: Heime @ 2022-11-06 13:40 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


How can I get values from an array to populate a list.  And vice versa, take a list to
make an array.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Array to list and vice versa
  2022-11-06 13:40 Array to list and vice versa Heime
@ 2022-11-06 13:58 ` Emanuel Berg
  2022-11-06 14:25 ` Stephen Berman
  1 sibling, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2022-11-06 13:58 UTC (permalink / raw)
  To: help-gnu-emacs

Heime wrote:

> How can I get values from an array to populate a list.

(seq--into-list "Sail Ho!") ; (83 97 105 108 32 72 111 33)

(seq--into-list [1 3 3 7]) ; (1 3 3 7)

> And vice versa, take a list to
> make an array.

(string-join (list "A" "B" "C")) ; "ABC"

Vector from list ... don't know?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Array to list and vice versa
  2022-11-06 13:40 Array to list and vice versa Heime
  2022-11-06 13:58 ` Emanuel Berg
@ 2022-11-06 14:25 ` Stephen Berman
  2022-11-06 14:40   ` Heime
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Berman @ 2022-11-06 14:25 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sun, 06 Nov 2022 13:40:26 +0000 Heime <heimeborgia@protonmail.com> wrote:

> How can I get values from an array to populate a list.

Is the array a vector or string?  Then:

(append '[1 2 3] nil)

or

(mapcar 'char-to-string "123")

> And vice versa, take a list to make an array.

To make a vector:

(vconcat '(1 2 3))

To make a string, it depends on the type of the list elements:

(mapconcat 'number-to-string '(1 2 3))
(mapconcat 'symbol-name '(a b c))

Steve Berman



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Array to list and vice versa
  2022-11-06 14:25 ` Stephen Berman
@ 2022-11-06 14:40   ` Heime
  0 siblings, 0 replies; 4+ messages in thread
From: Heime @ 2022-11-06 14:40 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor


------- Original Message -------
On Sunday, November 6th, 2022 at 2:25 PM, Stephen Berman <stephen.berman@gmx.net> wrote:


> On Sun, 06 Nov 2022 13:40:26 +0000 Heime heimeborgia@protonmail.com wrote:
> 
> > How can I get values from an array to populate a list.
> 
> 
> Is the array a vector or string? Then:

The array is made up of numbers.  [3 2 2 1 0]

> (append '[1 2 3] nil)
> 
> or
> 
> (mapcar 'char-to-string "123")
> 
> > And vice versa, take a list to make an array.
> 
> 
> To make a vector:
> 
> (vconcat '(1 2 3))

Thus, a vector looks like an ordinary list?
 
> To make a string, it depends on the type of the list elements:
> 
> (mapconcat 'number-to-string '(1 2 3))
> (mapconcat 'symbol-name '(a b c))
> 
> Steve Berman



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-06 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-06 13:40 Array to list and vice versa Heime
2022-11-06 13:58 ` Emanuel Berg
2022-11-06 14:25 ` Stephen Berman
2022-11-06 14:40   ` Heime

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).