ASPN ActiveState Programmer Network  
ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups
Submit Recipe
My Recipes

All Recipes
All Cookbooks


View by Category

Title: what words and phrases phone number spells
Submitter: Slava Lysunkin (other recipes)
Last Updated: 2007/08/10
Version no: 1.0
Category: Miscellaneous

 

Not Rated yet


Description:

This simple TCL script can generate all possible variants of pnone number spells using numbers and letters

Source: Text Source

array set recode {
	1 {1}		2 {2 A B C}	3 {3 D E F}
	4 {4 G H I}	5 {5 J K L}	6 {6 M N O}
	7 {7 P Q R S}	8 {8 T U V}	9 {9 W X Y Z}
			0 {0}
}

set number {2 6 7 7 4 6 8}

set results {}
set temp {}
set is_first 1

foreach i $number {

	set temp_list [split $recode($i) " "]

	if {$is_first} {
		set is_first 0
		foreach j $temp_list {
			lappend results $j
		}
	} else {
		foreach item $results {
			foreach j $temp_list {
				lappend temp "$item$j"
			}
		}
		set results $temp
		set temp {}
	}
}

foreach item $results {
	puts $item
}

The license for this recipe is available here.

Discussion:



Add comment

No comments.



Highest rated recipes:

1. A minimal debugger

2. Socket based communicatio...

3. With busy cursor

4. Multi-character split

5. LCD Number Display

6. Supporting mouse wheel ...

7. Get widget info

8. Check creditcard numbers ...

9. WSCP - showServerStatus

10. Inline GIF image into ...




Privacy Policy | Email Opt-out | Feedback | Syndication
© 2006 ActiveState Software Inc. All rights reserved.