Duck util-proc.

This commit is contained in:
Dominik Pantůček 2023-07-05 22:09:07 +02:00
parent 2f1589579e
commit a2c312741b
5 changed files with 109 additions and 64 deletions

View file

@ -274,3 +274,69 @@ most scheme implementations.
Returns a list containing only elements matching given ```pred?```
predicate.
## util-proc [module]
(import util-proc)
This module provides a few simple procedures for querying properties
of other procedures.
### improper-list-info [procedure]
(improper-list-info lst)
Returns two values: the proper part of the list length and #t if
there is an improper list end
### (procedure-arity=? n) [procedure]
((procedure-arity=? proc)
n)
* ```n``` - integer representing the number of arguments
* ```proc``` - procedure to query
Returns true if the procedure ```proc``` accepts exactly ```n```
arguments.
### (procedure-arity>=? n) [procedure]
((procedure-arity>=? proc)
n)
* ```n``` - integer representing the number of arguments
* ```proc``` - procedure to query
Returns true if the procedure ```proc``` accepts at least ```n```
arguments.
### (procedure-arity>? n) [procedure]
((procedure-arity>? proc)
n)
* ```n``` - integer representing the number of arguments
* ```proc``` - procedure to query
Returns true if the procedure ```proc``` accepts more than ```n```
arguments.
### procedure-num-args [procedure]
(procedure-num-args proc)
* ```proc``` - procedure to check
Returns the number of mandatory arguments.
### procedure-arg-names [procedure]
(procedure-arg-names proc)
* ```proc``` - procedure to check
Returns the (possibly improper) list of arguments the procedure
```proc``` accepts. If it accepts arbitrary number of arguments, it is
signalled by simple symbol instead of pair at the last position. If it
accepts an exact number of arguments, it returns a proper list.