unofficial mirror of 
 help / color / mirror / Atom feed
* Re: list-set! Wrong type argument in position 1 (expecting mutable pair)
       [not found] <>
@ 2020-08-26 20:22 ` Tim Van den Langenbergh
  0 siblings, 0 replies; only message in thread
From: Tim Van den Langenbergh @ 2020-08-26 20:22 UTC (permalink / raw)
  To: mbcladwell; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]


yeah, a quoted list is immutable (at least in Guile).

You could do something like...

(define my-list (list "zero" "one" "twooo")
(list-set! my-list 2 "two")

Don't forget that list-set! returns the new element, rather than the modified list.



On Wednesday, 26 August 2020 22:12:32 CEST you wrote:
> Hi,
> One shortcoming I find working with Guile is the limited number of
> examples of how to use code. Consider list-set!. The only reference in
> the entire Guile manual is the definition in section List
> Modification. If I google I find
> which gives me the
> example (list-set '(zero one two) 2 "two") ==> '(zero one "two") which
> is what I deduced from the Guile manual.  If I try something similar
> in Guile:
> scheme@(guile-user)> (list-set! '("zero" "one" "twooooo") 2 "two")
> ice-9/boot-9.scm:1669:16: In procedure raise-exception:
> In procedure set-car!: Wrong type argument in position 1 (expecting
> mutable pair): ("twooooo")
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,bt
>             1 (list-set! ("zero" "one" "twooooo") 2 "two")
> In ice-9/boot-9.scm:
> 1669:16  0 (raise-exception _ #:continuable? _)
> Could someone provide me with an example of how to use list-set! ?
> Alternatively what I really need is how to modify a specified element
> in a list.
> Thanks
> Mortimer

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-26 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <>
2020-08-26 20:22 ` list-set! Wrong type argument in position 1 (expecting mutable pair) Tim Van den Langenbergh

unofficial mirror of 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror guile-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-devel guile-devel/ \
	public-inbox-index guile-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git