Duck util-list.
This commit is contained in:
parent
1a2e9ee726
commit
2f1589579e
5 changed files with 34 additions and 21 deletions
|
@ -256,3 +256,21 @@ When the ```line``` contains whitespace character(s), it returns a
|
||||||
pair consisting of symbol created by interning the string of
|
pair consisting of symbol created by interning the string of
|
||||||
non-whitespace characters before the first whitespace character and
|
non-whitespace characters before the first whitespace character and
|
||||||
the string with the rest of the line.
|
the string with the rest of the line.
|
||||||
|
|
||||||
|
## util-list [module]
|
||||||
|
|
||||||
|
(import util-list)
|
||||||
|
|
||||||
|
This module implements basic list functionality which is common in
|
||||||
|
most scheme implementations.
|
||||||
|
|
||||||
|
### filter [procedure]
|
||||||
|
|
||||||
|
(filter pred?
|
||||||
|
lst)
|
||||||
|
|
||||||
|
* ```pred?``` - procedure accepting any value and returning #t or #f
|
||||||
|
* ```lst``` - list to be filtered
|
||||||
|
|
||||||
|
Returns a list containing only elements matching given ```pred?```
|
||||||
|
predicate.
|
||||||
|
|
15
doc/utils.md
15
doc/utils.md
|
@ -139,21 +139,6 @@ Converts given number to a string with two-digit fractional
|
||||||
part. Should the fractional part be 0, it is replaced with the string
|
part. Should the fractional part be 0, it is replaced with the string
|
||||||
"--".
|
"--".
|
||||||
|
|
||||||
### List
|
|
||||||
|
|
||||||
(import util-list)
|
|
||||||
|
|
||||||
This module implements basic list functionality which is common in
|
|
||||||
most scheme implementations.
|
|
||||||
|
|
||||||
(filter pred? lst)
|
|
||||||
|
|
||||||
* ```pred?``` - procedure accepting any value and returning #t or #f
|
|
||||||
* ```lst``` - list to be filtered
|
|
||||||
|
|
||||||
Returns a list containing only elements matching given ```pred?```
|
|
||||||
predicate.
|
|
||||||
|
|
||||||
### Mail
|
### Mail
|
||||||
|
|
||||||
(import util-mail)
|
(import util-mail)
|
||||||
|
|
|
@ -60,11 +60,11 @@ HACKERBASE-OBJS=hackerbase.o testing.o listing.o cal-month.o \
|
||||||
GENDOC-SOURCES=gendoc.scm duck-extract.import.scm \
|
GENDOC-SOURCES=gendoc.scm duck-extract.import.scm \
|
||||||
util-time.import.scm util-csv.import.scm util-git.import.scm \
|
util-time.import.scm util-csv.import.scm util-git.import.scm \
|
||||||
util-io.import.scm util-stdout.import.scm \
|
util-io.import.scm util-stdout.import.scm \
|
||||||
util-parser.import.scm
|
util-parser.import.scm util-list.import.scm
|
||||||
|
|
||||||
GENDOC-OBJS=gendoc.o duck-extract.o util-time.o util-csv.o util-io.o \
|
GENDOC-OBJS=gendoc.o duck-extract.o util-time.o util-csv.o util-io.o \
|
||||||
progress.o testing.o util-proc.o util-git.o util-io.o \
|
progress.o testing.o util-proc.o util-git.o util-io.o \
|
||||||
util-stdout.o util-parser.o
|
util-stdout.o util-parser.o util-list.o
|
||||||
|
|
||||||
.PHONY: imports
|
.PHONY: imports
|
||||||
imports: $(HACKERBASE-DEPS)
|
imports: $(HACKERBASE-DEPS)
|
||||||
|
@ -478,7 +478,7 @@ BOX-DRAWING-SOURCES=box-drawing.scm util-utf8.import.scm \
|
||||||
box-drawing.o: box-drawing.import.scm
|
box-drawing.o: box-drawing.import.scm
|
||||||
box-drawing.import.scm: $(BOX-DRAWING-SOURCES)
|
box-drawing.import.scm: $(BOX-DRAWING-SOURCES)
|
||||||
|
|
||||||
UTIL-LIST-SOURCES=util-list.scm testing.import.scm
|
UTIL-LIST-SOURCES=util-list.scm testing.import.scm duck.import.scm
|
||||||
|
|
||||||
util-list.o: util-list.import.scm
|
util-list.o: util-list.import.scm
|
||||||
util-list.import.scm: $(UTIL-LIST-SOURCES)
|
util-list.import.scm: $(UTIL-LIST-SOURCES)
|
||||||
|
|
|
@ -25,4 +25,5 @@
|
||||||
util-git
|
util-git
|
||||||
util-io
|
util-io
|
||||||
util-stdout
|
util-stdout
|
||||||
util-parser)
|
util-parser
|
||||||
|
util-list)
|
||||||
|
|
|
@ -25,8 +25,12 @@
|
||||||
|
|
||||||
(declare (unit util-list))
|
(declare (unit util-list))
|
||||||
|
|
||||||
(module
|
(import duck)
|
||||||
|
|
||||||
|
(module*
|
||||||
util-list
|
util-list
|
||||||
|
#:doc ("This module implements basic list functionality which is common in
|
||||||
|
most scheme implementations.")
|
||||||
(
|
(
|
||||||
filter
|
filter
|
||||||
util-list-tests!
|
util-list-tests!
|
||||||
|
@ -39,7 +43,12 @@
|
||||||
testing)
|
testing)
|
||||||
|
|
||||||
;; Returns a list with elements matching pred? predicate.
|
;; Returns a list with elements matching pred? predicate.
|
||||||
(define (filter pred? lst)
|
(define/doc (filter pred? lst)
|
||||||
|
("* ```pred?``` - procedure accepting any value and returning #t or #f
|
||||||
|
* ```lst``` - list to be filtered
|
||||||
|
|
||||||
|
Returns a list containing only elements matching given ```pred?```
|
||||||
|
predicate.")
|
||||||
(let loop ((lst lst)
|
(let loop ((lst lst)
|
||||||
(res '()))
|
(res '()))
|
||||||
(if (null? lst)
|
(if (null? lst)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue