Version 1 of dict filter

Updated 2010-11-10 10:40:34 by oehhar

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 !