{"size": 775, "ext": "scrbl", "max_stars_repo_path": "sugar/scribblings/len.scrbl", "max_stars_repo_name": "mbutterick/sugar", "max_stars_repo_stars_event_min_datetime": "2015-04-13T15:10:18.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-21T06:05:14.000Z", "max_issues_repo_path": "sugar/scribblings/len.scrbl", "max_issues_repo_name": "mbutterick/sugar", "max_issues_repo_issues_event_min_datetime": "2015-04-13T15:38:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-16T20:00:54.000Z", "max_forks_repo_path": "sugar/scribblings/len.scrbl", "max_forks_repo_name": "mbutterick/sugar", "max_forks_repo_forks_event_min_datetime": "2015-04-13T13:41:00.000Z", "max_forks_repo_forks_event_max_datetime": "2016-08-13T17:02:00.000Z"}
{"max_stars_count": 16, "max_issues_count": 18, "max_forks_count": 5, "avg_line_length": 25.8333333333, "max_line_length": 221, "alphanum_fraction": 0.6877419355}
#lang scribble/manual

@(require scribble/eval (for-label racket sugar))

@(define my-eval (make-base-eval))
@(my-eval `(require sugar))

@title{Len}
@defmodule[#:multi (sugar/len (submod sugar/len safe))]


@defproc[
(len
[x (or/c list? vector? set? string? symbol? path? hash?)])
integer?]
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.

@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)]