Subject: Re: looking up entries in a table of ranges
From: Erik Naggum <>
Date: 2000/02/07
Newsgroups: comp.lang.lisp
Message-ID: <>

* Jason Kantz
| I need to make a table that returns an entry for a value in a given
| range.  And I'm wondering if a more experienced programmer can comment
| on whether this is a common data structure with a common name.

  looks like a sorted association list to me.

(assoc 50.0 '((10.0 . "this stuff")
	      (40.0 . "this other stuff")
	      (100.0 . "yet some other stuff"))
       :test #'<=)
=> (100.0 . "yet some other stuff")

  FIND would allow you to use a sequence of more complex objects and use
  :KEY to extract the slot you want to look at.

  in any case, I would expect such a function to be called FIND-foo, foo
  being the object you're looking for.  whether you implement it as a
  general function traversing a list or a function with a fast TYPECASE
  dispatch on ranges is largely immaterial, though.