util
index
Python source

 
Package Contents
       
cl
dct
fnc
fs
lst
reflect
text
web

About

util is a collection of all the utilities I have created, plus some by Kaleb Captain and Jeremy McNeal. Contents are given below. This library is multi-lingual: Python, Scheme and Common Lisp are currently supported, although only Python's implementation is complete. Python 2.3 or above is required, and the newest version is recommended.

PLT Scheme with the Swindle language mode is required for the Scheme implementation, and any version of Common Lisp should work for the CL implementation, but only OpenMCL has been tested.

Making the code compatible with older versions of Python back to 1.5.2 should be possible, but not necessarily convenient. If you are interested in doing this, let me know. Python's support for functional and reflective techniques has improved in the last few years and these modules would be the most difficult to port.

Roadmap

The current version of the utility library is 1.5. The Python code and tests are complete, while Scheme and Common Lisp have several holes, particularly in reflect. Unit tests for Scheme and Common Lisp are missing with very few exceptions.

Version 1.6 will complete the code and tests for Scheme and Common Lisp.

Version 2.0 will complete the Common Lisp sequence library ports to Python and Scheme. These are available today (see module cl, but often do not match the Common Lisp semantics, are implemented in very inefficient ways, and are undocumented (see the Hyperspec in the meantime).

Subsequent versions will port the utility library to other languages. Good candidates are Javascript, Java, OCaml, Haskell, etc. There is no schedule for any of these versions. They may never happen. See the following section.

Getting Updates and Contributing

The current version will always be available at http://www.sandersn.com/util.zip. Currently, the source repository is stored at http://jones.ling.indiana.edu/~ncsander/repos/util/. This repository is managed by darcs: use darcs pull http://www.sandersn.com/util.zip to access it. Once you have made some changes, use darcs send to e-mail them to me. Any contributions are welcome.

Type Annotation

A note on type annotation. I use a notation which is similar to Haskell's notation, but is completely untested by a machine. (At least until this library is ported to a statically typed language). Here is how it works:

type1*type2 -> returntype

The arguments are on the left side of the arrow, separate by asterisks and the return type is on the right side of the arrow. Actual types are used as follows:

This looks lot like map
(a->b)*[a] -> [b]
Here is something that uses map to do something specific:
(int->str)*[int] -> [str]
This function takes a list of int 2-tuples and returns an int list
[(int*int)] -> [int]
This function has a variable arglist, but expects them all to be ints:
int... -> int

Destructively altered parameters are marked with ! (following Scheme, Ruby and to a lesser extent, Caml). There are not many such functions, and they are probably not all marked properly (at least until we get a Caml version of this library written).

Example:
str*{str:(int,int)}! -> str
Will modify the dict passed in some way. The documentation should explain how.

LICENCE (BSD licence)

Copyright (c) 2007, Nathan Sanders

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 
Download
        Current Version at http://www.sandersn.com/util.zip
        Repository at http://jones.ling.indiana.edu/~ncsander/repos/util/. Use darcs pull http://www.sandersn.com/util.zip to access it, or browse a copy of this page at http://jones.ling.indiana.edu/~ncsander/repos/util/util.html