Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language XOTcl

Date:04/20/05
Author:Philipp Winterberg
URL:http://www.winterbergs.de/
Comments:3
Info:http://www.xotcl.org
Score: (2.84 in 98 votes)
# XOTcl version of 99 Bottles of beer (Bottles.xotcl)
# http://www.xotcl.org
# Philipp Winterberg, http://www.winterbergs.de

for {set b 99} {$b > 0} {} {
  puts "$b bottle(s) of beer on the wall,"
  puts "$b bottle(s) of beer."
  puts "take one down, pass it around,"
  incr b -1
  puts "$b bottle(s) of beer on the wall.\n"
}

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Example using XOTcl specific constructsMark Janassen03/19/060

Comments

>>  Mark Janssen said on 03/19/06 05:04:17

Mark Janssen This is just plain Tcl. XOTcl would be something like:

package require XOTcl

namespace import ::xotcl::*


Class SingleBottle

SingleBottle instproc go {} {
puts -nonewline "1 bottle of beer on the wall, "
puts "1 bottle of beer."
puts -nonewline "Take one down, pass it around, "
puts "no bottles of beer on the wall.\n"
}

Class Beerwall -parameter number

Beerwall instproc go {} {
puts -nonewline "[my number] bottles of beer on the wall, "
puts "[my number] bottles of beer."
puts -nonewline "Take one down, pass it around, "
set number [expr {[my number] - 1}]
set b [Beerwall new -number $number]
if {[$b number] == 1 } {
$b mixin SingleBottle ; puts "1 bottle of beer on the wall."
} else {
puts "$number bottles of beer on the wall."
}
$b go
}


set b [Beerwall new -number 99]
puts [$b number]
$b go

>>  barrym said on 03/29/10 09:04:45

barrym More lazy-ass "bottle(s)" code. C'mon Phil, give us a conditional
expression or two. Geez Louise..........

>>  Gallagher27Christine said on 09/23/10 04:14:28

Gallagher27Christine I took 1 st <a href="http://bestfinance-blog.com/topics/home-loans">home loans</a> when I was 32 and that helped my business a lot. However, I need the auto loan as well.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: