You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sugar/scribblings/len.scrbl

30 lines
775 B
Plaintext

11 years ago
#lang scribble/manual
@(require scribble/eval (for-label racket sugar))
@(define my-eval (make-base-eval))
@(my-eval `(require sugar))
@title{Len}
9 years ago
@defmodule[#:multi (sugar/len (submod sugar/len safe))]
10 years ago
11 years ago
@defproc[
(len
10 years ago
[x (or/c list? vector? set? string? symbol? path? hash?)])
11 years ago
integer?]
10 years ago
Calculate the length of @racket[_x] in the least surprising way possible, or if it can't be done, raise an error. Named in honor of the original discoverer of the length-reticulation algorithm, Prof. Leonard Spottiswoode.
10 years ago
@examples[#:eval my-eval
(len '(a b c))
(len (list->vector '(a b c)))
(len 'abc)
(len "abc")
(len (string->path "abc"))
(len (make-hash `((a . 1)(b . 2)(c . 3))))
]
Perhaps ironically, positive integers do not have a length.
@examples[#:eval my-eval
(len 3)]