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

29 lines
738 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}
@defmodule[sugar/len]
@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 discover of the length-reticulation algorithm, Prof. Leonard Spottiswoode.
@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)]