From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John Cowan Newsgroups: gmane.lisp.guile.user Subject: Re: list-set! Wrong type argument in position 1 (expecting mutable pair) Date: Wed, 26 Aug 2020 16:42:36 -0400 Message-ID: References: <20200826151232.Horde.54lAstMht7PXoKcNHhj8vJT@www.stihie.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40009"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: mbcladwell@stihie.net Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 26 22:43:04 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kB2G6-000AHN-JF for guile-user@m.gmane-mx.org; Wed, 26 Aug 2020 22:43:02 +0200 Original-Received: from localhost ([::1]:44272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kB2G5-000386-L7 for guile-user@m.gmane-mx.org; Wed, 26 Aug 2020 16:43:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kB2Fv-00037w-C1 for guile-user@gnu.org; Wed, 26 Aug 2020 16:42:51 -0400 Original-Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:39363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kB2Ft-0007Ry-7A for guile-user@gnu.org; Wed, 26 Aug 2020 16:42:51 -0400 Original-Received: by mail-qt1-x82b.google.com with SMTP id 92so2748733qtb.6 for ; Wed, 26 Aug 2020 13:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yH3OlAV7XNeWkN5yGXw4ekapuK55t6wfkBSoGf//YZQ=; b=cajJ0DkCydpLECR19A+w3VdZynXCPiMbk7IsG4+HqCeS2gkHCh+HQiAKCMmjxzzgAv R0IxTKF6FokOT9bH+ElfOfyaIaG7m6Nd/xvKVDYT4th6rRPBLu7oJAGuCi8aJ3xaDhwq 5LUjWjqU1X7FKo+G5ML8GdDmFHfSGr6GPi0LvdqG7ECpQHGinFWn+sJH+oABjAMmAWtJ gHvMy9UajJkTRVu+/kQy5/n7wMMDZ82AC/rTGpfeAaZ3HhobJ25yY5Ae6QYh35DOc4nF v6bKCS1zwRhsA3AUhPiKNzzAcPsgzH3o28JOa/IZ+8FS+fBYM6cJ/OEsdvBv1R+65t+M juYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yH3OlAV7XNeWkN5yGXw4ekapuK55t6wfkBSoGf//YZQ=; b=pmURwDcvO5L8ydcQOXLLDbVg3kkgdU5lYH+hkzwrRO+YtiHHmiWO1MuCZF4FldTIrN /He9jx2pCKTaZ+T0rITqR+DcKqGEwAj4qf9lpkq58pT78b4xNynQzgIp9tgedhxhvh71 fFslQ8zAt/eCvDRAkguBLx+24mGsiCaZzpcO3pwf26Em5JPuEaeGhRdtFIz7ZNkdkj1f snk3Q6duvqq/Pgb5o9zCNt5Jzor5f6+CcStU54VLPNP5DfIyDdgkbMr2n71Lc9c2zUKs mTY54chG8t0rQBoMDRXSRIjt910ix944965krGBUFF/8X9fZN0ob58tWUw5Wt/qQ6jfF pcEg== X-Gm-Message-State: AOAM5329izKOytRyDxpDNpiizNQx3I8GywhnRz3049TcIjxFJezheb9i CBWEcJl9n668iSupJAgYNpE9Ja1y1M/Bdev60q4JCcsn26h59w== X-Google-Smtp-Source: ABdhPJxORMnX5saJadGW17ndlA/1sT7DKoaPfT6j3Mc2ucesqOnILUQM1HleDTMk/GTHH+QOVdNXx03lcfUZqmhl808= X-Received: by 2002:ac8:1084:: with SMTP id a4mr14961343qtj.83.1598474567383; Wed, 26 Aug 2020 13:42:47 -0700 (PDT) In-Reply-To: <20200826151232.Horde.54lAstMht7PXoKcNHhj8vJT@www.stihie.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=cowan@ccil.org; helo=mail-qt1-x82b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16839 Archived-At: First of all, Racket's pairs are immutable, so it provides list-set (non-destructive) rather than list-set!. Second, it is an error to mutate a literal, since that amounts to self-modifying code. Some Schemes don't enforce that, but Guile does. So you need (list-set! (list "one" "twoooo" three") 2 "two"), which constructs the list at run time using the list function. On Wed, Aug 26, 2020 at 4:13 PM 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 6.6.9.6 List > Modification. If I google I find > https://docs.racket-lang.org/reference/pairs.html 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 > > >