Home  >  Article  >  WeChat Applet  >  Example code for adding Tcl applet from 1 to 100

Example code for adding Tcl applet from 1 to 100

高洛峰
高洛峰Original
2017-03-27 13:15:093914browse

I have been doing testing for nearly two years, and my usual time is occupied by work that is too busy to play. Haha, after calming down, I feel that I still need to learn something, but the working machine is not good enough. I have a little exposure to Tcl language in my daily work. There is a great person in the company who uses it, and it is really useful. So I started to learn it myself, I am still a little interested in programming, haha.

How to learn? Just reading is not enough, let’s practice to promote learning. I used for loop and while loop to write a small program that adds from 1 to 100. Although it looks simple, it still costs a lot of money. Lack of energy, previous incomprehension, either this or that mistake. Take your time, haha, cheer yourself up!

for {set i 1;set j 0} {$i<=100} {incr i 1} {
set j [expr ($j+$i)]
} ; return $j ;

set i 1
set j 0
while {$i<=100} {
set j [expr ($ j+$i)]
set i [expr ($i+1)]
} ; return $j ;

I feel that when learning something new, you need patience at first, and then perseverance. Well, haha, because it’s easy to be anxious at first, but then it’s easy to give up. . .

[created by liweikui, May 6,2009]

The above is the detailed content of Example code for adding Tcl applet from 1 to 100. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn