Random Bits of Open Code

Check-in [e6d9fe4acc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:rename function any? to any-defined?
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e6d9fe4acce79a6b7210d05061dd8ea47e0a5fde
User & Date: mrwellan 2018-05-10 14:57:51
Context
2018-05-11
09:43
use more portable names for the /tmp/ areas check-in: 4b007bc17a user: matt tags: trunk
2018-05-10
14:57
rename function any? to any-defined? check-in: e6d9fe4acc user: mrwellan tags: trunk
2018-05-09
06:19
Merged/melded margs.scm from Megatest into opensrc/margs check-in: 477df8bc03 user: matt tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to margs/margs.scm.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    (
     arg-hash
     get-arg
     get-arg-from
     usage
     get-args
     print-args
     any?
     help
     )

(import scheme chicken data-structures extras posix ports files)

(use srfi-69 srfi-1)

................................................................................
(define help "")

(define (get-arg arg . default)
  (if (null? default)
      (hash-table-ref/default arg-hash arg #f)
      (hash-table-ref/default arg-hash arg (car default))))

(define (any? . args)
  (not (null? (filter (lambda (x) x)
		      (map get-arg args)))))

(define (get-arg-from ht arg . default)
  (if (null? default)
      (hash-table-ref/default ht arg #f)
      (hash-table-ref/default ht arg (car default))))
................................................................................
      (apply print "ERROR: " args))
  (if (string? help)
      (print help)
      (print "Usage: " (car (argv)) " ... "))
  (exit 0))

 ;; one-of args defined
(define (any-defined? . param)
  (let ((res #f))
    (for-each 
     (lambda (arg)
       (if (get-arg arg)(set! res #t)))
     param)
    res))








|







 







|







 







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    (
     arg-hash
     get-arg
     get-arg-from
     usage
     get-args
     print-args
     any-defined?
     help
     )

(import scheme chicken data-structures extras posix ports files)

(use srfi-69 srfi-1)

................................................................................
(define help "")

(define (get-arg arg . default)
  (if (null? default)
      (hash-table-ref/default arg-hash arg #f)
      (hash-table-ref/default arg-hash arg (car default))))

(define (any-defined? . args)
  (not (null? (filter (lambda (x) x)
		      (map get-arg args)))))

(define (get-arg-from ht arg . default)
  (if (null? default)
      (hash-table-ref/default ht arg #f)
      (hash-table-ref/default ht arg (car default))))
................................................................................
      (apply print "ERROR: " args))
  (if (string? help)
      (print help)
      (print "Usage: " (car (argv)) " ... "))
  (exit 0))

 ;; one-of args defined
#;(define (any-defined? . param)
  (let ((res #f))
    (for-each 
     (lambda (arg)
       (if (get-arg arg)(set! res #t)))
     param)
    res))