The details of returning a null value in case of "not found"
is among the least of the problems with this application.



----- Original Message -----
From: Dan Bron <[email protected]>
Date: Friday, February 26, 2010 11:33
Subject: Re: [Jprogramming] Dictionary AKA hash
To: 'Programming forum' <[email protected]>

> Andrew Nikitin wrote:
> >  What is the reference implementation of dictionary AKA hash?
> 
> If your keys are strings, there is always  s:  (maybe 
> this uses the same hashing algorithm that supports J's name 
> mechanisms?) .
> You still have to do the  i.  thing but it should be 
> faster than using boxed strings.  Depends on how large your 
> universe is.
> 
> Roger wrote:
> >   Probably best to avoid the phrase (V,a:) or
> >   (V,nullvalue) in get.  .  Better to use 
> something like
> >   V {~ :: (nullvalue"_)  
> 
> No way!  That's scalar programming at its ugliest.  
> One bad key spoils the bunch.  Or you have to apply get at 
> small rank - a no-no.
> 
> There has to be a better way.  Barring special code for the 
> idiom, maybe use the special support for append in place [1], inside
> put?   That is, in the definition of put, insert this 
> line between  end.  and  i.0 0 
> 
>       V=:V, a:   NB.  Default invalid keys
> 
> >  Another is to use J's built in ability to search for a 
> name in locale.
> >  This one just does not feel right.
> 
> I agree that it doesn't feel right, but this is probably the 
> best option (in terms of convenience and performance).  
> Depending on
> the kinds of keys you're dealing with, the "namification" 
> process could have low overhead.   For general keys 
> (i.e. arbitrary
> nouns), you could always do something along the lines of  
> tobase64 3!:1 y  .  
> 
> -Dan
>  
> [1]  http://www.jsoftware.com/help/release/apip.htm
> 
> 
> -----------------------------------------------------------------
> -----
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to