[erlang-questions] questions about dict

Bjorn Gustavsson bjorn@REDACTED
Tue Aug 21 08:09:48 CEST 2007


Dustin Sallings <dustin@REDACTED> writes:

> 	There are a couple of things about dict I'm working around in some  
> of my programs and was wondering if there's a better way or something.
> 
> 	1)  There doesn't seem to be a way to get the length of a dict  
> directly, although it seems to be directly stored (I'm using fold  
> right now to calculate it).

Use orddict:size/1.

It seems to be undocumented for no good reason. We will update the
documentation in R12B.
 
> 	2)  I can't seem to make a guard for a dict because the record  
> format is unavailable to me at compile time (I'm working around this  
> by matching tuple and hard-coding a tuple pattern for identifying a  
> dict).

That is intentional (and even mentioned in the documentation).

There is no portable way to test for a dict in a guard.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list