s c h e m a t i c s : c o o k b o o k

/ NoParentSelected / Cookbook.HashChapter

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Hashes

Introduction

PLT Scheme provides basic, but useful and fast ways of manipulating hashes. A hash table is used to store a collection of data values associated with keys.

To create a hash table use make-hash-table, which receives two optional arguments to create tables with weakly-held keys, and to use different comparison procedures. We will discuss this variations later, so for the time being something like:

(make-hash-table)

creates a new hash table. By default this table will compare keys using eq?. If you want to use keys that need a stronger equality test (i.e., strings), you can provide make-hash-table with the argument equal:

(make-hash-table 'equal)

In the following recipes we will discuss ways to manipulate our newly created hash table.

Recipes



(edit comments)

Comments

Small comment: maybe we should avoid the use of the word "hash", since that's become a Perl term with lots of associations. Also, maybe we should have a breakdown of what Perl hashes are used for and how they map to different concepts and idioms in Scheme and PLT Scheme. (Someone who knows recent Perl versions better than I do would ideally volunteer...)

-- NeilVanDyke - 14 Jun 2004

I'd like to see some discussion of assoc lists vs. hashes. I always use assoc lists because it's convenient, what are the advantages of hashes over assq/assv/assoc?

-- GordonWeakliem - 17 Sep 2004

Contributors

-- KarlaRamirez - 19 May 2004

CookbookForm
TopicType: Chapter
ParentTopic: TOC
TopicOrder: 08

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest