[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/11: doc: cookbook: Mention common SRFI-1 procedures.
From: |
guix-commits |
Subject: |
03/11: doc: cookbook: Mention common SRFI-1 procedures. |
Date: |
Mon, 14 Aug 2023 18:34:37 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit d20a7da4a38e96ded5bda1aab2df75f2eee2af85
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Aug 14 15:08:00 2023 +0200
doc: cookbook: Mention common SRFI-1 procedures.
* doc/guix-cookbook.texi (A Scheme Crash Course): Add item about
SRFI-1.
---
doc/guix-cookbook.texi | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/doc/guix-cookbook.texi b/doc/guix-cookbook.texi
index 28303df37b..ee66dad7d9 100644
--- a/doc/guix-cookbook.texi
+++ b/doc/guix-cookbook.texi
@@ -192,7 +192,8 @@ rest are the arguments passed to the function. Every
function returns the
last evaluated expression as its return value.
@item
-Anonymous functions are declared with the @code{lambda} term:
+Anonymous functions---@dfn{procedures} in Scheme parlance---are declared
+with the @code{lambda} term:
@lisp
(lambda (x) (* x x))
@@ -208,6 +209,9 @@ which can in turn be applied to an argument:
@result{} 9
@end lisp
+Procedures are regular values just like numbers, strings, Booleans, and
+so on.
+
@item
Anything can be assigned a global name with @code{define}:
@@ -233,6 +237,30 @@ A list structure can be created with the @code{list}
procedure:
@result{} (2 3 5 7)
@end lisp
+@item
+Standard procedures are provided by the @code{(srfi srfi-1)} module to
+create and process lists (@pxref{SRFI-1, list processing,, guile, GNU
+Guile Reference Manual}). Here are some of the most useful ones in
+action:
+
+@lisp
+(use-modules (srfi srfi-1)) ;import list processing procedures
+
+(append (list 1 2) (list 3 4))
+@result{} (1 2 3 4)
+
+(map (lambda (x) (* x x)) (list 1 2 3 4))
+@result{} (1 4 9 16)
+
+(delete 3 (list 1 2 3 4)) @result{} (1 2 4)
+(filter odd? (list 1 2 3 4)) @result{} (1 3)
+(remove even? (list 1 2 3 4)) @result{} (1 3)
+(find number? (list "a" 42 "b")) @result{} 42
+@end lisp
+
+Notice how the first argument to @code{map}, @code{filter},
+@code{remove}, and @code{find} is a procedure!
+
@item
@cindex S-expression
The @dfn{quote} disables evaluation of a parenthesized expression, also
- branch master updated (d55d2a971b -> 355f2073fb), guix-commits, 2023/08/14
- 03/11: doc: cookbook: Mention common SRFI-1 procedures.,
guix-commits <=
- 02/11: doc: cookbook: Add 'use-modules' in gexp example., guix-commits, 2023/08/14
- 06/11: gnu: highlight: Update to 4.7., guix-commits, 2023/08/14
- 11/11: gnu: fennel: Update to 1.3.1., guix-commits, 2023/08/14
- 04/11: doc: Add reference to the Scheme Crash Course., guix-commits, 2023/08/14
- 08/11: gnu: highlight: Add "gui" output., guix-commits, 2023/08/14
- 09/11: gnu: highlight: Fix paths for Perl bindings., guix-commits, 2023/08/14
- 07/11: gnu: highlight: Use new package style., guix-commits, 2023/08/14
- 01/11: doc: cookbook: Link to "Package Modules"., guix-commits, 2023/08/14
- 10/11: gnu: llama-cpp: Update to 0.0.0-0.f31b539., guix-commits, 2023/08/14
- 05/11: gnu: guile-smc: Update to 0.6.2., guix-commits, 2023/08/14