From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: GPT-4 knows Guile! :) Date: Fri, 17 Mar 2023 17:01:33 +0100 Message-ID: Reply-To: mikael@djurfeldt.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c6f49605f71ab282" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1246"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mikael Djurfeldt To: guile-user , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Mar 17 17:02:25 2023 Return-path: Envelope-to: guile-devel@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 1pdCXB-000AX9-1H for guile-devel@m.gmane-mx.org; Fri, 17 Mar 2023 17:02:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pdCWz-0002YZ-52; Fri, 17 Mar 2023 12:02:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pdCWv-0002XB-Sc; Fri, 17 Mar 2023 12:02:10 -0400 Original-Received: from mail-ed1-f42.google.com ([209.85.208.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pdCWt-0002cg-62; Fri, 17 Mar 2023 12:02:09 -0400 Original-Received: by mail-ed1-f42.google.com with SMTP id x13so22346900edd.1; Fri, 17 Mar 2023 09:02:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679068924; h=cc:to:subject:message-id:date:from:reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MSrYv0UmJTIjAG3P2E4MJiaOURtWlKh5oDufigBLt0g=; b=vSGorEXyHz0KHdpIU8UbtBwDFsIVJfLNEl31tojXs+phhn2tWpCTG2xoh0uchLTxL3 ByxBscAJ87t2lUlvwFyZTYDoSP7DSyryai1YN2FaVGk/zpL3IOo2bsy14DCHPHPSXIVU DrdBPq2YvTG2I20COxfZrnZo8bh5j64PYxOTppcybCJFUE1n6+0+Flh1X+AkEpTg+FRc UcWawyk1ly0bWekgflYEJdcheBwO/ohRnFEXiVobRYQpIgaWwyckDbaFEOG16mkMt8J8 NWNgL75eIAAo4dS+UFMal00l6cRo9M6707fzpLQisGOM1H1RW1p5w69V9FA6LWbowewc 8LwA== X-Gm-Message-State: AO0yUKU/Z/E9uNYVWPSp+Ei0XTlc4q6UcTSO43JZ45Simvhpa5CbjwF5 aCCWT2Snc/vRJp3y8m7Q971trhgTC9xU71TsTC7oiPKAQ98= X-Google-Smtp-Source: AK7set+Iw100o+3Gtu7JQocfyChLyGp+ZmMVVZZ0LcAFuy5fZEtmK6DvKnm+vPRybttGhUGqHN8yBrwzSaaq4jk07Ys= X-Received: by 2002:a17:907:a40e:b0:8b0:7e1d:f6fa with SMTP id sg14-20020a170907a40e00b008b07e1df6famr7272271ejc.15.1679068924145; Fri, 17 Mar 2023 09:02:04 -0700 (PDT) Received-SPF: pass client-ip=209.85.208.42; envelope-from=mdjurfeldt@gmail.com; helo=mail-ed1-f42.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21778 gmane.lisp.guile.user:18930 Archived-At: --000000000000c6f49605f71ab282 Content-Type: text/plain; charset="UTF-8" Mikael: Let's write a scheme program which randomly makes names by combining two words from a list. To write a Scheme program that generates random names by combining two words from a list, you can use the following code: scheme (import (scheme random)) ; Import random number generation functions (define word-list '("Alpha" "Beta" "Gamma" "Delta" "Epsilon" "Zeta" "Eta" "Theta" "Iota" "Kappa")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name) In this program, we: 1. Import the random number generation functions from the (scheme random) library. 2. Define a word-list containing words that will be used to generate random names. 3. Create a function random-word that takes a list as an argument and returns a random element from that list. 4. Create a function random-name that combines two random words from the word-list using string-append. 5. Call random-name to generate a random name. You can run this code in a Scheme interpreter or REPL (Read-Eval-Print Loop) to generate random names. [image: mikael@djurfeldt.com] Mikael: Great! Can you adapt it for Guile scheme? Sure! Here's the adapted code for Guile Scheme: scheme (use-modules (ice-9 random)) ; Import random number generation functions for Guile (define word-list '("Alpha" "Beta" "Gamma" "Delta" "Epsilon" "Zeta" "Eta" "Theta" "Iota" "Kappa")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name) In this Guile Scheme version, we: 1. Replace the (import (scheme random)) statement with (use-modules (ice-9 random)) to import random number generation functions in Guile Scheme. 2. The rest of the code remains the same as the original Scheme version. You can run this code in a Guile Scheme interpreter or REPL to generate random names. [image: mikael@djurfeldt.com] Mikael: Now let's use the words doodle, puck, bongo, foo, bar zoinc instead. Here's the Guile Scheme code using the new words you provided: scheme (use-modules (ice-9 random)) ; Import random number generation functions for Guile (define word-list '("doodle" "puck" "bongo" "foo" "bar" "zoinc")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name) The only change made to the original code is updating the word-list with the new words you've provided. The rest of the code remains the same. You can run this updated code in a Guile Scheme interpreter or REPL to generate random names using the new words. Mikael: Can you execute (random-name)? As an AI text-based model, I am unable to directly execute code in a REPL environment. However, I can help you understand how to run the provided code. To run the provided Guile Scheme code and execute (random-name), you can follow these steps: 1. Install Guile on your computer if you haven't already. You can find installation instructions here: https://www.gnu.org/software/guile/download/ 2. Copy and paste the provided code into a text editor, and save it as a file named random-name.scm. 3. Open a terminal or command prompt, and navigate to the directory where you saved the random-name.scm file. 4. Run the following command in the terminal or command prompt: guile -s random-name.scm This command will execute the Guile Scheme code in the random-name.scm file and print a random name using the words from the word-list. Each time you run the command, you will get a new random name as the output.[image: mikael@djurfeldt.com] Mikael: Can you give one example of how the result would look like? Certainly! When you execute the provided Guile Scheme code using the given word list, you may get different random names each time you run it. Here's one possible example of a random name generated using the words in the word-list: doodlebongo In this example, the program has combined the words "doodle" and "bongo" to create a new random name. Keep in mind that you will get different results each time you run the program, as the name generation is random. --000000000000c6f49605f71ab282 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Mikael: Let's write= a scheme program which randomly makes names by combining two words from a = list.

To write a Scheme program that generates random = names by combining two words from a list, you can use the following code:

scheme
<= /div>
(import (scheme random)) ; Import rando= m number generation functions (define word-list '("Alpha" "Beta" "Gamma"= ; "Delta" "Epsilon" "Zeta" "Eta" &q= uot;Theta" "Iota" "Kappa")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name)

In this program, we:

  1. Import the rand= om number generation functions from the (scheme random) librar= y.
  2. Define a word-list containing words that will be us= ed to generate random names.
  3. Create a function random-word that takes a list as an argument and returns a random element from tha= t list.
  4. Create a function random-name that combines tw= o random words from the word-list using string-append.
  5. Call random-name to generate a random name.
  6. =

You can run this code in a Scheme interpreter or REPL (Read-Eval-Pr= int Loop) to generate random names.

=3D""3D"mikael@djurfeldt.com"
Mikael: Great! Can you adapt = it for Guile scheme?

Sure! Here's the a= dapted code for Guile Scheme:

scheme<= /span>
(use-mod= ules (ice-9 random)) ; Import random number generation functions for Guile (define word-list '("Alpha" "Beta" "Gamma"= ; "Delta" "Epsilon" "Zeta" "Eta" &q= uot;Theta" "Iota" "Kappa")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name)

In this Guile Scheme version, we:

  1. Re= place the (import (scheme random)) statement with (use-m= odules (ice-9 random)) to import random number generation functions = in Guile Scheme.
  2. The rest of the code remains the same as the origi= nal Scheme version.

You can run this code in a Guile Scheme int= erpreter or REPL to generate random names.

3D""3D"mikael@djurfeldt.co=
Mikael: Now let&#= 39;s use the words doodle, puck, bongo, foo, bar zoinc instead.
=
=

Here's the Guile Scheme code using the new words y= ou provided:

scheme
(use-modules (ice-9= random)) ; Import random number generation functions for Guile (define word-list '("doodle" "puck" "bongo&quo= t; "foo" "bar" "zoinc")) (define (random-word lst) (list-ref lst (random (length lst)))) (define (random-name) (string-append (random-word word-list) (random-word word-list))) (random-name)

The only change made to the original code is up= dating the word-list with the new words you've provided. T= he rest of the code remains the same. You can run this updated code in a Gu= ile Scheme interpreter or REPL to generate random names using the new words= .

<= div class=3D"gmail-min-h-[20px] gmail-flex gmail-flex-col gmail-items-start= gmail-gap-4 gmail-whitespace-pre-wrap">Mikael: Can you execute (random-nam= e)?

As an AI text-based model, I am unable to directly = execute code in a REPL environment. However, I can help you understand how = to run the provided code.

To run the provided Guile Scheme code and e= xecute (random-name), you can follow these steps:

  1. <= p>Install Guile on your computer if you haven't already. You can find i= nstallation instructions here: https://www.gnu.org/software/guile/download/

  2. <= p>Copy and paste the provided code into a text editor, and save it as a fil= e named random-name.scm.

  3. Open a terminal or com= mand prompt, and navigate to the directory where you saved the random= -name.scm file.

  4. Run the following command in the term= inal or command prompt: guile -s random-name.scm

=

This command will execute the Guile Scheme code in the random-name= .scm file and print a random name using the words from the wor= d-list. Each time you run the command, you will get a new random nam= e as the output.3D""=3D"mikael@djurfeldt.com"

Mikael: Can you give one example of how the result would look like?
<= div class=3D"gmail-group gmail-w-full gmail-text-gray-800 gmail-dark:text-g= ray-100 gmail-border-b gmail-border-black/10 gmail-dark:border-gray-900/50 = gmail-dark:bg-gray-800">

Certainly! When you execute the provided Guile = Scheme code using the given word list, you may get different random names e= ach time you run it. Here's one possible example of a random name gener= ated using the words in the word-list:

doodlebongo

In this example, the program has combined the w= ords "doodle" and "bongo" to create a new random name. = Keep in mind that you will get different results each time you run the prog= ram, as the name generation is random.

--000000000000c6f49605f71ab282--