[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some questions (was Re: Some doubts)

Paulo Matos writes:
> Since I've been programming in Common Lisp for some time I'm
> having some trouble knowing the names of the functions I want.
> I'm sure you can help me with the following questions:
> 1 - In Common Lisp when I need to search for a function
> specification or a function that does something I go to
> the Hyperspec, what should I do when I have the same problem with
> Scheme?

Scheme in general: R5RS.  MzScheme: try Help Desk in DrScheme, which
has a "find docs for" text search, which searches R5RS as well as
documentation specific to DrScheme, MzScheme, and MrEd.  The indexing
leaves something to be desired; MzScheme has built-in support for TCP
sockets, for example, but searching for "socket" won't tell you that.
(And I can't tell you where to find the documentation because Help
Desk doesn't show URLs by default.  Search for "network".)

Whether this is fortunate or unfortunate is a matter of much argument,
but you will find that the libraries provided with MzScheme are much
smaller than the ones included in Common Lisp.

> 2 - How can I remove (without consing, i.e. destructively) an
> element from a list?

You want to set a cdr?  Use 'set-cdr!'.  But if you want something
like the Common Lisp "delete", you'll have to write it yourself, or
get it from SLIB (it's under (require 'common-list-functions)).  (The
documentation for the Debian potato version of SLIB (slib2c7))
doesn't say SLIB works with MzScheme, but I'm sure it wouldn't be too
hard to make "delete" work with MzScheme, and the version currently at
http://swissnet.ai.mit.edu/~jaffer/SLIB.html says it works with

A fairly complete set of list-handling operations is in SRFI 1 (Common
Lisp/SLIB delete is called delete!, while remove is called delete), an
implementation of which is included in SLIB, and there is a reference
implementation of SRFI 1 at

> 2.1 - Following the question above I should probably pass a
>   function to the remove function above (called delete in CL)
>   telling it how to compare the objects (maybe eq? by default in
>   Scheme). How can I pass that optional parameter...
> I do know that rest parameters are:
> (define foo (arg1 arg2 . restargs)
>         null)
> But how about optional and key parameters?

If you want them, you have to extract them from "restargs" yourself,
perhaps with assq.  As a result, key parameters are used less in
Scheme than in Common Lisp.

> 3 - How can I print a hash-table for example in a different way
> than its default way defined by implementation? (without defining
> a function to do it explicitly... I would like to overload
> something as a print-object method or something...)

I don't know because, when it comes to Scheme, I am an ignorant

<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
> Then the object is collected. The finalizer is not run a second time.
Can you cast a spell to resoul an undead object? Do the resouled undead
differ from the living? -- Charles Fiterman on gclist@iecc.com