2021-03-23

The Name Game

You are given a $name.

Write a script to display the lyrics to the Shirley Ellis song The Name Game. Please checkout the wiki page for more information.

#!/usr/bin/env tclsh
#
# You are given a $name.
# Write a script to display the lyrics to
# the Shirley Ellis song The Name Game.
#
if {$argc >= 1} {
    set xname [lindex $argv 0]
} elseif {$argc == 0} {
    puts "Please input a string"
    exit    
}

if {[string length $xname] <= 1} {
    puts "Please give a longer string"
    exit
}

set yname [string range $xname 1 end]
puts "$xname, $xname, bo-b$yname"
puts "Bonana-fanna fo-f$yname"
puts "Fee fi mo-m$yname"
puts "$xname!"

沒有留言: