Version 2 of dict filter

Updated 2011-07-21 13:45:03 by FabricioRocha

Subcommand of dict that returns a subset of a dictionary according to some filtering rule.

dict filter dictionaryValue key globPattern
dict filter dictionaryValue value globPattern
dict filter dictionaryValue script { keyVar valueVar } script

HaO: an example session with the script option:

% set d [dict filter {k1 v1 k2 v2} script {k v} {return [expr {$k eq "k1"}]}]
1

So return might not be the right command. It stops the script and nothing is assigned to d.

Lets try without it:

% set d [dict filter {k1 v1 k2 v2} script {k v} {expr {$k eq "k1"}}]
k1 v1

That worked !


Fabricio Rocha - 21 Jul 2011 - Could anyone who know the dict internals tell about how does the search performed by dict filter works? And how it performs in comparison to searches made with dict for and other "manual", script-based search methods?