Update library a little.
This commit is contained in:
parent
8b28cd478b
commit
eb7960e231
20
lib.rkt
20
lib.rkt
|
@ -20,8 +20,7 @@
|
||||||
(define ∂r curryr)
|
(define ∂r curryr)
|
||||||
|
|
||||||
;; uncurry : (a1 -> ... -> an -> b) -> ((listof a) -> b)
|
;; uncurry : (a1 -> ... -> an -> b) -> ((listof a) -> b)
|
||||||
(define uncurry
|
(define uncurry (curry apply))
|
||||||
(curry apply))
|
|
||||||
(define $ uncurry)
|
(define $ uncurry)
|
||||||
|
|
||||||
;; iterate : (a -> a) -> number -> (a -> a)
|
;; iterate : (a -> a) -> number -> (a -> a)
|
||||||
|
@ -61,12 +60,12 @@
|
||||||
;; String helpers ;;
|
;; String helpers ;;
|
||||||
|
|
||||||
;; string->number* : (or/c string? #f) -> (or/c number? #f)
|
;; string->number* : (or/c string? #f) -> (or/c number? #f)
|
||||||
(define (string->number* s)
|
(define string->number*
|
||||||
(and (string? s) (string->number s)))
|
(and/c string? string->number))
|
||||||
|
|
||||||
;; string->symbol* : (or/c string? #f) -> (or/c symbol? #f)
|
;; string->symbol* : (or/c string? #f) -> (or/c symbol? #f)
|
||||||
(define (string->symbol* s)
|
(define string->symbol*
|
||||||
(and (string? s) (string->symbol s)))
|
(and/c string? string->symbol))
|
||||||
|
|
||||||
;; string->binary : string? -> number?
|
;; string->binary : string? -> number?
|
||||||
;; Given a string representation of a binary number,
|
;; Given a string representation of a binary number,
|
||||||
|
@ -105,9 +104,8 @@
|
||||||
(not (char=? c1 c2)))
|
(not (char=? c1 c2)))
|
||||||
|
|
||||||
;; char-alphanumeric? : char -> boolean
|
;; char-alphanumeric? : char -> boolean
|
||||||
(define (char-alphanumeric? c)
|
(define char-alphanumeric?
|
||||||
(or (char-alphabetic? c)
|
(or/c char-alphabetic? char-numeric?))
|
||||||
(char-numeric? c)))
|
|
||||||
|
|
||||||
|
|
||||||
;; Number helpers ;;
|
;; Number helpers ;;
|
||||||
|
@ -159,7 +157,9 @@
|
||||||
|
|
||||||
;; singleton? : (listof any) -> boolean
|
;; singleton? : (listof any) -> boolean
|
||||||
(define (singleton? lst)
|
(define (singleton? lst)
|
||||||
(= 1 (length lst)))
|
(match lst
|
||||||
|
[(list _) true]
|
||||||
|
[else #f]))
|
||||||
|
|
||||||
;; snoc : (listof any) -> any -> (listof any)
|
;; snoc : (listof any) -> any -> (listof any)
|
||||||
;; Append element to the back of the list.
|
;; Append element to the back of the list.
|
||||||
|
|
Loading…
Reference in New Issue