-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmlib.html
1458 lines (965 loc) · 41.4 KB
/
mlib.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Default Library Reference for Murmel, a Lisp dialect.">
<meta name="keywords" content="murmel, murmel-lang, lisp, lisp-dialect">
<title>Murmel Default Library Reference</title>
<script>window.texme = { useMathJax: false, protectMath: false }</script>
<script src="https://cdn.jsdelivr.net/npm/texme@1.2.2"></script>
</head>
<textarea>
# Mlib - Default library for Murmel
mlib adds commonly used Lisp functions and macros to the
[core Murmel language (see murmel-langref.html)](murmel-langref.html).
Most of mlib's functions and macros are modeled after Common Lisp,
(often with reduced functionality) plus some additional macros and functions.
## Usage
Copy `mlib.lisp` into the directory containing `jmurmel.jar`
or into the directory specified with `--libdir`
and begin your source file with
(require "mlib")
## mlib functions and macros
mlib provides the following Common Lisp-like functions and macros:
- logic, program structure
- [when](#macro-when), [unless](#macro-unless)
- [not](#function-not), [and](#macro-and), [or](#macro-or)
- [prog1, prog2](#macro-prog1-prog2)
- [case](#macro-case), [typecase](#macro-typecase)
- conses and lists
- [caar..cdddr](#function-caarcdddr), [nthcdr, dotted-nthcdr, nth](#function-nthcdr-dotted-nthcdr-nth), [endp](#function-endp)
- [copy-list](#function-copy-list), [copy-alist](#function-copy-alist), [copy-tree](#function-copy-tree)
- [list-length](#function-list-length), [last](#function-last), [butlast](#function-butlast), [nbutlast](#function-nbutlast), [ldiff](#function-ldiff), [tailp](#function-tailp)
- [subst](#function-subst), [subst-if](#function-subst-if), [nsubst](#function-nsubst), [nsubst-if](#function-nsubst-if)
- [nconc](#function-nconc), [revappend, nreconc](#function-revappend-nreconc), [member](#function-member), [adjoin](#function-adjoin)
- [acons](#function-acons)
- [mapcar](#function-mapcar), [maplist](#function-maplist), [mapc](#function-mapc), [mapl](#function-mapl), [mapcan](#function-mapcan), [mapcon](#function-mapcon)
- [multiple-value-list](#macro-multiple-value-list), [nth-value](#macro-nth-value)
- iteration
- [do, do*](#macro-do-do), [dotimes](#macro-dotimes), [dolist](#macro-dolist)
- places
- [destructuring-bind](#macro-destructuring-bind)
- [get-setf-expansion](#function-get-setf-expansion)
- [setf](#macro-setf), [psetf](#macro-psetf), [shiftf](#macro-shiftf), [rotatef](#macro-rotatef)
- [incf, decf](#macro-incf-decf)
- [push](#macro-push), [pop](#macro-pop), [pushnew](#macro-pushnew)
- numbers, characters
- [abs](#function-abs), [min](#function-min), [max](#function-max), [zerop](#function-zerop), [evenp](#function-evenp), [oddp](#function-oddp)
- [char=](#function-char), [char](#function-char-1), [bit](#function-bit)
- [parse](#function-parse), [parse-integer](#function-parse-integer)
- sequences
- [elt](#function-elt), [copy-seq](#function-copy-seq), [length](#function-length)
- [reverse](#function-reverse), [nreverse](#function-nreverse)
- [remove-if](#function-remove-if), [remove](#function-remove)
- [concatenate](#function-concatenate)
- [map](#function-map), [map-into](#function-map-into), [reduce](#function-reduce)
- hash tables
- [gethash](#function-gethash), [remhash](#function-remhash), [maphash](#function-maphash)
- higher order
- [identity](#function-identity), [constantly](#function-constantly), [complement](#function-complement)
- [every](#function-every), [some](#function-some), [notevery](#function-notevery), [notany](#function-notany)
- I/O
- [write-char](#function-write-char)
- [terpri, prin1, princ, print](#function-terpri-prin1-princ-print), [pprint](#function-pprint)
- [format](#function-format), [formatter](#macro-formatter)
- [error](#function-error)
- [with-output-to-string](#macro-with-output-to-string)
- misc
- [time](#macro-time)
functions and macros inspired by [Alexandria](https://alexandria.common-lisp.dev):
- conses and lists
- [circular-list](#function-circular-list)
- [mappend](#function-mappend), [mappend-tails](#function-mappend-tails)
- iteration
- [doplist](#macro-doplist)
- higher order
- [compose](#function-compose), [multiple-value-compose](#function-multiple-value-compose)
- [conjoin](#function-conjoin), [disjoin](#function-disjoin)
- [curry](#function-curry), [rcurry](#function-rcurry)
- misc
- [with-gensyms](#macro-with-gensyms)
functions inspired by [SRFI-1](https://srfi.schemers.org/srfi-1/srfi-1.html)
- conses and lists
- [unzip](#function-unzip)
functions and macros inspired by [serapeum](https://github.com/ruricolist/serapeum/blob/master/REFERENCE.html)
- conses and lists
- [plist-keys](#function-plist-keys), [plist-values](#function-plist-values)
- misc
- [with-accumulator](#macro-with-accumulator), [summing](#macro-summing), [collecting](#macro-collecting), [reverse-collecting](#macro-reverse-collecting)
as well as the following additional functions and macros:
- logic and program structure
- [->](#macro), [->>](#macro-1), [and->](#macro-and-1), [and->>](#macro-and-2)
- conses and lists
- [unzip-tails](#function-unzip-tails)
- iteration
- [dovector](#macro-dovector), [dogenerator](#macro-dogenerator)
- places
- [*f, /f, +f, -f](#macro-f-f)
- generators
- [scan](#function-scan), [scan-multiple](#function-scan-multiple), [scan-concat](#function-scan-concat)
- strings
- [string-trim](#function-string-trim), [string-subseq](#function-string-subseq), [string-replace](#function-string-replace), [string-split](#function-string-split), [string-join](#function-string-join)
- hash tables
- [frequencies](#function-frequencies)
## Description of functions and macros
### Macro: when
(when condition forms*) -> result
Since: 1.1
Execute `forms` if `condition` evaluates to true
and return the result of the last form if any.
Otherwise if `condition` evaluates to false,
the forms are not evaluated and the return value
of the `when`-form is `nil`.
### Macro: unless
(unless condition forms*) -> result
Since: 1.1
Execute `forms` if `condition` evaluates to false
and return the result of the last form if any.
Otherwise if `condition` evaluates to true,
the forms are not evaluated and the return value
of the `unless`-form is `nil`.
### Function: not
(not form) -> boolean
Since: 1.1
Logical not.
### Macro: and
(and forms*) -> result
(and* forms*) -> boolean
Since: 1.1
Short-circuiting logical and.
Return `t` if no forms were given,
otherwise return the values resulting from the evaluation of the last form unless any of the `forms` evaluate to `nil`,
`nil` otherwise,
or in case of `and*`: `t` or `nil` as appropriate.
### Macro: or
(or forms*) -> result
(or* forms*) -> boolean
Since: 1.1
Short-circuiting logical or.
Return `nil` unless any of the `forms` evaluate to non-nil,
the result of the first form returning non-nil otherwise,
or in case of `or*`: `t` or `nil` as appropriate.
### Macro: prog1, prog2
(prog1 first-form more-forms*) -> result-1
(prog2 first-form second-form more-forms*) -> result-2
Since: 1.1
### Macro: case
(case keyform (keys forms*)* [(t forms*)]) -> result
Since: 1.1
`keys` can be a single key or a list of keys, keys will not be evaluated.
`keyform` will be matched against `keys` using `eql`, the `forms` of the
matching clause will be eval'd and the last form determines the result.
Subsequent clauses will be ignored.
A clause with a key that is a single `t` is used as the default clause
if no key matches.
### Macro: typecase
(typecase keyform (type forms*)* [(t forms*)]) -> result
Since: 1.3
`typecase` allows the conditional execution of a body of forms in a clause
that is selected by matching the test-key on the basis of its type.
The keyform is evaluated to produce the test-key.
Each of the normal-clauses is then considered in turn.
If the test-key is of the type given by the clauses's type,
the forms in that clause are evaluated as an implicit progn,
and the values it returns are returned as the value of the typecase form.
If no normal-clause matches, and there is an otherwise-clause,
then that otherwise-clause automatically matches;
the forms in that clause are evaluated as an implicit progn,
and the values it returns are returned as the value of the typecase.
If there is no otherwise-clause, typecase returns nil.
### Function: caar..cdddr
(c..r lst) -> result
Since: 1.1
`c..r` repeatedly apply `car` and/ or `cdr` as the name suggests.
### Function: endp
(endp list) -> boolean
Since: 1.4.6
This is the recommended way to test for the end of a proper list. It
returns true if `obj` is `nil`, false if `obj` is a `cons`,
and a `type-error` for any other type of `object`.
### Function: nthcdr, dotted-nthcdr, nth
(nthcdr n lst) -> nth-tail
(dotted-nthcdr n lst) -> nth-tail
(nth n lst) -> nth-element
Since: 1.1
`nthcdr` applies `cdr` n times and returns the result.
`dotted-nthcdr` works similar to `nthcdr` except:
going past the end of a dotted list returns `nil`
(and not an error as `nthcdr` would).
`nth` works as if `(car (nthcdr n lst))` was invoked.
### Function: copy-list
(copy-list lst) -> copy
Since: 1.3
Returns a copy of `lst`. If `lst` is a dotted list,
the resulting list will also be a dotted list.
Only the list structure of `lst` is copied;
the elements of the resulting list are the same
as the corresponding elements of the given list.
### Function: unzip
(unzip lists) -> result-list
Since: 1.2
`unzip` takes a list of lists, and returns a list
containing the initial element of each such list,
e.g.:
(unzip '((1 2) (11 22) (111 222))) ; ==> (1 11 111)
(unzip '(nil nil nil)) ; ==> (nil nil nil)
(unzip nil) ; ==> nil
Similar to SRFI-1 `unzip1`, see https://srfi.schemers.org/srfi-1/srfi-1.html#unzip1.
See also: [unzip-tails](#function-unzip-tails).
### Function: unzip-tails
(unzip-tails lists) -> result-list
Since: 1.2
`unzip-tails` takes a list of lists, and returns a list
containing the `cdr`s of each such list.
See also: [unzip](#function-unzip).
### Function: list-length
(list-length list) -> length
Since: 1.1
Returns the length of `list` if it is a string or proper list.
Returns `nil` if `list-or-string` is a circular list.
### Function: last
(last lst [n]) -> tail
Since: 1.2
`last` returns the last `n` conses (not the last `n` elements)
of a proper or dotted list or `nil` for the empty list.
If `n` is zero, the atom that terminates list is returned.
If `n` is greater than or equal to the number of cons cells in list,
the result is `lst`.
### Function: nconc
(nconc lists*) -> concatenated-list
Since: 1.2
`nconc` concatenates lists, each list but the last is modified.
If no lists are supplied, `nconc` returns `nil`.
Each argument but the last must be a proper or dotted list.
### Function: revappend, nreconc
(revappend list tail) -> result-list
(nreconc list tail) -> result-list
Since: 1.3
`revappend` constructs a copy of `list`, but with the elements in reverse order.
It then appends (as if by `nconc`) the `tail` to that reversed list and returns the result.
`nreconc` reverses the order of elements in list (as if by `nreverse`).
It then appends (as if by `nconc`) the tail to that reversed list and returns the result.
The resulting list shares list structure with tail.
(revappend x y) ::= (append (reverse x) y)
(nreconc x y) ::= (nconc (nreverse x) y)
### Function: member
(member item list [test]) -> tail
Since: 1.1
`member` searches list for `item` or for a top-level element that
satisfies the `test`.
`test` if given must be a function that takes two arguments.
If `test` was omitted or `nil` then `eql` will be used.
Example usage:
(member 2 '(1 2 3))
; => (2 3)
(member 'e '(a b c d))
; => NIL
(member '(1 . 1) '((a . a) (b . b) (c . c) (1 . 1) (2 . 2) (3 . 3))
equal)
; => ((1 . 1) (2 . 2) (3 . 3))
(member 'c '(a b c 1 2 3) eq)
; => (c 1 2 3)
(member 'b '(a b c 1 2 3) (lambda (a b) (eq a b)))
; => (b c 1 2 3)
### Function: adjoin
(adjoin item list [test]) -> result-list
Since: 1.4.5
Tests whether `item` is the same as an existing element of `lst`.
If the `item` is not an existing element, `adjoin` adds it to `lst` (as if by `cons`)
and returns the resulting list; otherwise, nothing is added and the original list is returned.
### Function: acons
(acons key datum alist) -> new-alist
Since: 1.1
Prepends `alist` with a new `(key . datum)` tuple
and returns the modified list.
### Function: mapcar
(mapcar function list+) -> list
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent items of the given lists.
All `function` application results will be combined into a list
which is the return value of `mapcar`.
### Function: maplist
(maplist function list+) -> list
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent tails of the given lists.
All `function` application results will be combined into a list
which is the return value of `maplist`.
### Function: mapc
(mapc function list+) -> first-arg
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent cars items of the given lists.
### Function: mapl
(mapl function list+) -> first-arg
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent tails of the given lists.
### Function: mapcan
(mapcan function list+) -> concatenated-results
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent items of the given lists.
All function application results will be concatenated (as if by nconc) to a list
which is the return value of `mapcan`.
### Function: mapcon
(mapcon function list+) -> concatenated-results
Since: 1.1
`function` must accept as many arguments as lists are given,
and will applied to subsequent tails of the given lists.
All function application results will be concatenated (as if by nconc) to a list
which is the return value of `mapcon`.
### Function: mappend
(mappend function list+) -> appended-results
Since: 1.4.7
`function` must accept as many arguments as lists are given,
and will applied to subsequent items of the given lists.
All function application results will be concatenated to a list
which is the return value of `mappend`.
`function` must return a list which will not be mutated by `mappend`.
`mappend` works similar to Alexandria's `mappend` and
can be thought of as a non-destructive version of `mapcan`,
i.e. `mappend` combines the results of applying `function`
by the use of `append` rather than `nconc`.
### Function: mappend-tails
(mappend-tails function list+) -> appended-results
Since: 1.4.7
`function` must accept as many arguments as lists are given,
and will applied to subsequent tails of the given lists.
All function application results will be concatenated to a list
which is the return value of `mappend-tails`.
`function` must return a list which will not be mutated by `mappend-tails`.
`mappend-tails` can be thought of as a non-destructive version of `mapcon`,
i.e. `mappend-tails` combines the results of applying `function`
by the use of `append` rather than `nconc`.
### Macro: multiple-value-list
Since: 1.4
### Macro: nth-value
Since: 1.4
### Macro: do, do*
(do ({var | (var [init-form [step-form]])}*)
(end-test-form result-form*)
statement*) -> result
(do* ({var | (var [init-form [step-form]])}*)
(end-test-form result-form*)
statement*) -> result
Since: 1.1
`do` and `do*` iterate over a group of statements while `end-test-form` returns `nil`.
### Macro: dotimes
(dotimes (var count-form result-form*) statement*) -> result
Since: 1.1
Similar to CL `dotimes`.
Murmel however supports multiple result-forms which will be eval'd in an
implicit `progn`, similar to `do` and `do*`;
Sample usage:
(let (l)
(dotimes (i 10 l)
(push i l))) ; ==> (9 8 7 6 5 4 3 2 1 0)
### Macro: dolist
(dolist (var list-form result-form*) statement*) -> result
Since: 1.1
Similar to CL `dolist`.
Murmel however supports multiple result-forms which will be eval'd in an
implicit `progn`, similar to `do` and `do*`;
### Macro: dovector
(dovector (var vector-form result-form*) statement*) -> result
Since: 1.3
Just like `dolist`, but with vectors.
### Macro: doplist
(doplist (key-var value-var plist-form result-form*)
statement*) -> result
Since: 1.2
Iterates over key-value pairs of `plist-form`.
Similar to Alexandria `doplist`,
see https://alexandria.common-lisp.dev/draft/alexandria.html.
### Function: copy-alist
(copy-alist alist) -> new-alist
Since: 1.4.6
`copy-alist` returns a copy of `alist`.
The list structure of `alist` is copied, and the elements of `alist` which are conses are also copied (as conses only).
Any other objects which are referred to, whether directly or indirectly, by the `alist` continue to be shared.
### Function: copy-tree
(copy-tree tree) -> new-tree
Since: 1.4.6
Creates a copy of a tree of conses.
If `tree` is not a `cons`, it is returned;
otherwise, the result is a new cons of the results of calling `copy-tree` on the car and cdr of `tree`.
In other words, all conses in the tree represented by `tree` are copied recursively,
stopping only when non-conses are encountered.
copy-tree does not preserve circularities and the sharing of substructure.
### Function: butlast
(butlast lst [n]) -> result-list
Since: 1.4.5
`butlast` returns a copy of `lst` from which the last `n` conses have been omitted.
If `n` is not supplied, its value is 1. If there are fewer than `n` conses in `lst`,
`nil` is returned.
### Function: nbutlast
(nbutlast lst [n]) -> result-list
Since: 1.4.5
`nbutlast` is like `butlast`, but `nbutlast` may modify `lst`.
It changes the cdr of the cons n+1 from the end of `lst` to `nil` except
if there are fewer than `n` conses in `lst`, `nil` is returned
and `lst` is not modified.
### Function: ldiff
(ldiff lst obj) -> result-list
Since: 1.4.5
Return a new list, whose elements are those of `lst` that appear before
`obj`. If `obj` is not a tail of `lst`, a copy of `lst` is returned.
`lst` must be a proper list or a dotted list.
### Function: tailp
(tailp obj lst) -> boolean
Since: 1.4.5
Return `true` if `obj` is the same as some tail of `lst`, otherwise
returns `false`. `lst` must be a proper list or a dotted list.
### Function: subst
(subst new old tree [test-fn [key-fn]]) -> new-tree
Since: 1.4.6
Substitutes `new` for subtrees of `tree` matching `old`.
### Function: subst-if
(subst-if new test-pred tree [key-fn]) -> new-tree
Since: 1.4.6
Substitutes `new` for subtrees of `tree` for which `test-pred` is true.
### Function: nsubst
(nsubst new old tree [test-fn [key-fn]]) -> new-tree
Since: 1.4.6
Substitutes `new` for subtrees of `tree` matching `old`.
### Function: nsubst-if
(nsubst-if new test-pred tree [key-fn]) -> new-tree
Since: 1.4.6
Substitutes `new` for subtrees of `tree` for which `test-pred` is true.
### Macro: destructuring-bind
(destructuring-bind (vars*) expression forms*)
Since: 1.1
Murmel's `destructuring-bind` is a subset of CL's `destructuring-bind`,
trees are not supported, only lists are.
`destructuring-bind` binds the variables specified in `vars`
to the corresponding values in the list resulting from the evaluation
of `expression`; then `destructuring-bind` evaluates `forms`.
### Function: get-setf-expansion
(get-setf-expansion place) -> vars, vals, store-vars, writer-form, reader-form
Since: 1.1
### Macro: setf
(setf pair*) -> result
Since: 1.1
Takes pairs of arguments like `setq`. The first is a place and the second
is the value that is supposed to go into that place. Returns the last
value. The place argument may be any of the access forms for which `setf`
knows a corresponding setting form, which currently are:
- symbols
- car..cdddr
- nth
- elt, seqref
- hashref, gethash
- svref, bvref, bit, sref, char
- values
### Macro: psetf
(psetf pair*) -> nil
Since: 1.4.6
Takes pairs of arguments like `setf`. The first is a place and the second
is the value that is supposed to go into that place.
If more than one pair is supplied then the assignments of new values to places are done in parallel.
Similar to CL's `psetf`.
### Macro: shiftf
(shiftf place+ newvalues) -> old-values-1
Since: 1.4.8
`shiftf` modifies the values of each place by storing newvalue into the last place,
and shifting the values of the second through the last place into the remaining places.
Similar to CL's `shiftf`.
### Macro: rotatef
(rotatef place*) -> nil
Since: 1.4.8
`rotatef` modifies the values of each place by rotating values from one place into another.
If a place produces more values than there are store variables, the extra values are ignored.
If a place produces fewer values than there are store variables, the missing values are set to `nil`.
Similar to CL's `rotatef`.
### Macro: incf, decf
(incf place [delta-form]) -> new-value
(decf place [delta-form]) -> new-value
Since: 1.1
`incf` and `decf` are used for incrementing and decrementing
the value of `place`, respectively.
The delta is added to (in the case of `incf`) or subtracted
from (in the case of `decf`) the number in `place` and the result
is stored in `place`.
Without `delta-form` the return type of `incf` and `decf` will be
the type of the number in `place`, otherwise the return type will be float.
### Macro: *f, /f
(*f place [delta-form]) -> new-value
(/f place [delta-form]) -> new-value
Since: 1.1
`*f` and `/f` are used for multiplying and dividing
the value of `place`, respectively.
The number in `place` is multiplied (in the case of `*f`) by delta
or divided (in the case of `/f`) by delta and the result
is stored in `place`.
Without `delta-form` `/f` will return the reciprocal of the number in `place`,
`*f` will return the number in `place`.
Without `delta-form` the return type of `*f` will be
the type of the number in `place`, otherwise the return type will be float.
### Macro: +f, -f
(+f place [delta-form]) -> new-value
(-f place [delta-form]) -> new-value
Since: 1.1
`+f` and `+f` are used for adding and subtracting
to/ from the value of `place`, respectively.
The delta is added (in the case of `+f`) to
or subtracted (in the case of `-f`) from the number in `place`
and the result is stored in `place`.
Without `delta-form` `-f` will return the negation of the number in `place`,
`+f` will return the number in `place`.
Without `delta-form` the return type of `+f` will be
the type of the number in `place`, otherwise the return type will be float.
### Macro: push
(push item place) -> new-place-value
Since: 1.1
`push` prepends `item` to the list that is stored in `place`,
stores the resulting list in `place`, and returns the list.
### Macro: pushnew
(pushnew item place [test]) -> new-place-value
Since: 1.4.5
`pushnew` tests whether `item` is the same as any existing element of the list stored in `place`.
If `item` is not, it is prepended to the list, and the new list is stored in `place`.
`pushnew` returns the new list that is stored in `place`.
### Macro: pop
(pop place) -> element
Since: 1.1
`pop` reads the value of `place`, remembers the car of the list which
was retrieved, writes the cdr of the list back into the `place`,
and finally yields the car of the originally retrieved list.
### Function: abs
(abs number) -> result
Since: 1.1
Return the absoute value of a number.
### Function: min
(min number+) -> result
Since: 1.4
Return the smallest number of the given arguments.
### Function: max
(max number+) -> result
Since: 1.4
Return the largest number of the given arguments.
### Function: zerop
(zerop number) -> boolean
Since: 1.1
Is this number zero?
### Function: evenp
(evenp number) -> boolean
Since: 1.1
Is this number even?
### Function: oddp
(oddp number) -> boolean
Since: 1.1
Is this number odd?
### Function: char=
(char= characters+) -> boolean
Since: 1.1
Return `t` if all of the arguments are the same character.
### Function: char
(char str n) -> nth-character
Since: 1.1
Return the n-th character of the string `str`, `n` is 0-based.
### Function: bit
(bit bv n) -> nth bit
Since: 1.3
Return the n-th bit of the bitvector `bv`, `n` is 0-based.
### Function: parse
(parse result-type str [eof-obj [start [end]]]) -> result
Since: 1.4
Reads the token in `str` starting at `start` (which defaults to `0`),
`parse-error` if the token is not of type `result-type`.
### Function: parse-integer
(parse-integer str [start [end]]) -> result
Since: 1.4
Reads the token in `str` starting at `start` (which defaults to `0`),
`parse-error` if the token is not of type `integer`.
### Function: scan
(scan start [step [endincl]]) -> generator-function that returns subsequent numbers starting from `start` incrementing by `step` (default: 1)
(scan seq-or-gen [start-idx [stop-idx-excl]]) -> generator-function that returns subsequent elements of the given sequence (list or vector) or generator
(scan hash-table) -> generator-function that returns subsequent (key . value) pairs of the given hash-table
Since: 1.3
`scan` creates a generator function that on subsequent calls produces subsequent values.
`start-idx` and `stop-idx-excl` if given must be integer numbers >= 0, both are 0-based.
A generator function takes no arguments and on subsequent applications returns `(values <next-value> t)`
or `(values <undefined-value> nil)` to indicate "all values are exhausted".
### Function: scan-multiple
(scan-multiple generator+) -> generator
Since: 1.3
`scan-multiple` combines several generators into a single generator function
that returns a list with subsequent values of all generators,
and whose secondary value is nil if any generator returns nil as their secondary value.
Once the first generator indicates "at end" for the first time no more generators will be called.
### Function: scan-concat
(scan-concat generator+) -> generator
Since: 1.3
`scan-concat` combines several generators into a single generator function
that acts as if the given generators were concatenated.
A single generator would be returned unchanged.
### Macro: dogenerator
(dogenerator (var generator-form result-form*) statement*) -> result
Since: 1.3
`dogenerator` creates a generator by eval'ing `generator-form`
and iterates over the values yielded by subsequent generator applications.
### Function: elt
(elt sequence n) -> nth-element
Since: 1.3
Similar to CL `elt`, Murmel's `elt` handles dotted lists, though.
### Function: copy-seq
(copy-seq sequence) -> copied-sequence
Since: 1.3
Creates a copy of `sequence`.
The elements of the new sequence are the same as the corresponding elements of the given sequence.
If `sequence` is a vector, the result is a fresh simple vector
that has the same actual array element type as `sequence`.
If `sequence` is a list, the result is a fresh list.
### Function: length
(length sequence) -> length
Since: 1.1
Returns the length of `sequence`.
### Function: reverse
(reverse sequence) -> reversed-sequence
Since: 1.1
If `sequence` is a list then return a fresh list
with elements in reversed order, if `sequence`
is a vector then return a fresh reversed vector.
### Function: nreverse
(nreverse sequence) -> reversed-sequence
Since: 1.3
Similar to `reverse` `nreverse` returns a sequence with elements in reversed order.
`nreverse` however may or may not reuse/ destroy the input sequence.
### Function: remove-if
(remove-if pred sequence) -> sequence
Since: 1.1
Return a fresh sequence without the elements for which `pred`
evaluates to non-nil.
### Function: remove
(remove elem sequence) -> sequence
Since: 1.1
Return a fresh sequence without occurrences of `elem`.
An occurrence is determined by `eql`.
### Function: concatenate
(concatenate result-type sequences*) -> result-sequence
Since 1.4.7
`concatenate` returns a sequence that contains all the individual elements
of all the sequences in the order that they are supplied.
The sequence is of type result-type, which must be a subtype of type sequence.
All of the sequences are copied from; the result does not share any structure
with any of the sequences.
### Function: map
(map result-type function sequences+) -> result
Since 1.3
Applies `function` to successive sets of arguments in which one argument
is obtained from each sequence. The function is called first on all the elements
with index 0, then on all those with index 1, and so on.
The result-type specifies the type of the resulting sequence.
`map` returns `nil` if `result-type` is `nil`. Otherwise, `map` returns a sequence
such that element j is the result of applying `function` to element j of each
of the sequences. The result sequence is as long as the shortest of the sequences.
Similar to CL `map`.
### Function: map-into
(map-into result-sequence function sequence*) -> result-sequence
Since: 1.2
Destructively modifies `result-sequence` to contain the results
of applying `function` to each element in the argument sequences in turn.
The iteration terminates when the shortest sequence (of any of
the sequences or the result-sequence) is exhausted.
If `result-sequence` is `nil`, `map-into` returns `nil`.
Similar to CL `map-into`.
### Function: reduce
(reduce func sequence [from-end-p]) -> result
Since: 1.1
If `sequence` is empty then `reduce` will return `(func)`.
Otherwise if `sequence` contains one element then `reduce` will
return this element.
Otherwise if `from-end-p` is omitted or `nil` then
`func` will be called with the first two elements
of the `sequence` and subsequently with the previous result
and the next element, and `reduce` will return the last
result from `func`.