GTP utilities
If you think one of these functions should "graduate" to another library or package, let me know at: github.com/bennn/gtp-util/issues
procedure
(filename/c x) → boolean?
x : any/c
> (filename/c "segfault.mp3") #t
> (filename/c (build-path "code.rkt")) #t
> (filename/c (build-path "Desktop" "passwd.txt")) #f
procedure
(nonnegative-real/c x) → boolean?
x : any/c
> (nonnegative-real/c 0) #t
> (nonnegative-real/c (sqrt 2)) #t
> (nonnegative-real/c -2) #f
procedure
c : contract?
> ((unique-listof/c symbol?) '(u n i q)) #t
> ((unique-listof/c symbol?) '(r e p e a t)) #f
procedure
(confidence-interval r* [ #:cv confidence-value]) → (cons/c real? real?) r* : (listof real?) confidence-value : nonnegative-real/c = 1.96
procedure
(path-string->string ps) → string?
ps : path-string?
procedure
(path-string->path ps) → path?
ps : path-string?
procedure
(ensure-directory ps) → void?
ps : path-string?
Assumes n is a power of 2.
procedure
ps : path-string?
procedure
out-path : path-string? p : pict?
procedure
(force/cpu-time thunk) →
any/c natural? thunk : (-> any/c)
procedure
(time-string->values str) →
exact-nonnegative-integer? exact-nonnegative-integer? exact-nonnegative-integer? str : string?
> (time-string->values (with-output-to-string (λ () (time (sleep 1) (collect-garbage 'minor)))))
14
1014
14
> (let ([time-str (with-output-to-string (λ () (time (sleep 1) (collect-garbage 'minor))))]) (values (time-string->cpu-time time-str) (time-string->real-time time-str) (time-string->gc-time time-str)))
42
1042
42
procedure
(bitstring? x) → boolean?
x : any/c
> (bitstring? "0011") #t
> (bitstring? 3) #f
> (bitstring? " 1") #f
procedure
(natural->bitstring n #:bits k) → string?
n : natural? k : natural?
procedure
(bitstring->natural str) → natural?
str : string?
procedure
(count-zero-bits str) → natural?
str : string?
procedure
(copy-file* src dst [pattern]) → void?
src : directory-exists? dst : directory-exists? pattern : string? = "*.*"
procedure
(copy-racket-file* src dst) → void?
src : directory-exists? dst : directory-exists?
procedure
(copy-directory/files* src dst [pattern]) → void?
src : directory-exists? dst : directory-exists? pattern : string? = "*"
See also in-indexed and in-naturals.
procedure
(integer->digit* i) → (listof digit/c)
i : exact-integer?
> (integer->digit* 8675309) '(8 6 7 5 3 0 9)
> (integer->digit* 0) '(0)
procedure
(digit*->integer d*) → exact-integer?
d* : (listof digit/c)
> (digit*->integer '(9 1 1)) 911
procedure
(filename-sort ps*) → (listof filename/c)
ps* : (listof filename/c)
> (filename-sort (list (build-path "foo.md") (build-path "bar.rkt"))) '(#<path:bar.rkt> #<path:foo.md>)
procedure
(whitespace-string? str) → boolean?
str : string?
> (whitespace-string? " \n \t") #t
> (whitespace-string? "X") #f
procedure
(simple-comment-string? str) → boolean?
str : string?
> (simple-comment-string? " ;") #t
> (simple-comment-string? " #;(a b c)") #f
> (simple-comment-string? " #|") #f
procedure
(string->value str) → any/c
str : string?
> (string->value "#true") #t
> (string->value "#(A B (C))") '#(A B (C))
1 System Calls
(require gtp-util/system) | package: gtp-util |
See also racket/system.
procedure
cmd : path-string? arg* : (or/c path-string? (listof path-string?))
procedure
filename : path-string?