Wednesday, April 23, 2025

Remove Duplicate Words from a String

 

The lmap command will loop over each item (x) in the list (str) and if it 

 

 proc removeDuplicates {str} {
    set res ""

    lmap x $str { if {$x ni $res} {lappend res $x} }

    return $res
}

No comments: