I don't understand why my 8.6 tcl version does understand a for loop like this: "for{set i 0}{$i<10}{incr i}{ [closed] - tcl

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 days ago.
Improve this question
I am using the tclsh interpreter and the Synopsis Primetime shell. Both are not supporting that kind of loop. is there something that I am missing here?
Thanks a lot
I am trying to perform a very standard for loop

I think you just a syntax error. This works for me:
for {set x 0} {$x<10} {incr x} {
puts "x is $x"
}
Outputs:
x is 0
x is 1
x is 2
x is 3
x is 4
x is 5
x is 6
x is 7
x is 8
x is 9

Related

Octave - How to plot an "infinite"(= Defining the function on [0:35916] for me) sawtooth function [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I know how to plot a sawtooth function (thanks to another forum) but only on the domain [0:10] thanks to the following code which is actually working :
t=0:0.04:10;
A=1;
T=1;
rho= mod(t * A / T, A);
plot(t,rho)
A=the amplitude, T=the period,t=the time interval.
The problem is that I need the same function on the domain [0:35916] but when I try to adapt this code to do so (eg by extending the time interval), I get an error and I don't understand why.
error:
plt2vv: vector lengths must match error: called from plt>plt2vv at line 487 column 5 plt>plt2 at line 246 column 14 plt at line 113 column 17 plot at line 222 column 10
Simply modifying the original upper limit of your interval from 10 to 35916 should do the trick:
t=0:0.04:35916;
A=1;
T=1;
rho= mod(t * A / T, A);
plot(t,rho)
The code above yields the following image:
Of course it is up to you to adjust A and T to suit your needs.

Fatal: Syntax error, ")"expected but identifier found [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
TOTAL [X] :=
(0.1 tomat*harga tomat ) + (0.2 cabe*harga cabe) + (0.3 kol*harga kol)+
(0.4 ikan*hargaikan)+ (0.5 tahun*hargatahu) + (0.6 tahu*harga tahu);
Each of the six sub expressions has syntax errors. For instance
0.1 tomat*harga tomat
You can't omit operators like you do in maths. So perhaps what you meant is
0.1 * tomat * harga * tomat
Or perhaps harga tomat is meant to be a single variable. Variable names cannot contain spaces. So you'd need to rename it without a space.

function in Haskell that can solve an equation [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to write a function in Haskell that can solve the following problem(physic_problem):
What is the height (in a whole number of meters) of the shortest building that you could drop a ball from such that it would take at least 5 seconds to hit the ground?
The equation can be found here http://en.wikipedia.org/wiki/Equations_for_a_falling_body
I really tried hard on this and i need help!
Thank you so much!
Consider for instance this,
g :: Double
g = 9.81
dist :: Double -> Double
dist t = g * t^2 / 2
Then,
> dist 5
122.625
Additionally you may want to create a module out of the equations in that Wiki.
Update
For delivering an integral value consider for example
dist' :: (Integral a) => Double -> a
dist' t = ceiling $ g * t^2 / 2
Here we use ceiling (upper bound), yet note Converting to Integral for other rounding functions. Hence,
> dist' 5
123

ROUND IN SQL Works but for this case what to do in MYSQL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to round the decimals like :
1.00 ->1.0
1.987->1.98
1.93-> 1.93
1.07->1.07
How to do this in mysql?
Here goes some documentation
http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_round
Quick answer:
mysql> SELECT ROUND(1.987, 2); = 1.99
OR More what you are looking for
truncate(1.987, 2) = 1.98
From Mysql decimal: floor instead of round
This only makes a difference if you are outputting the number (numerically, 1.0 = 1.00). So:
(case when format(num, 2) = '1.00' then '1.0' else format(num-0.005, 2) end)
The -0.005 is to overcome the fact that format() rounds rather than truncates.
Just like that:
SELECT if(NUMBER mod 1=0,ROUND(NUMBER,1),ROUND(NUMBER,2));
eg.
SELECT IF(1.00 MOD 1=0,ROUND(1.00,1),ROUND(1.00,2)); => 1.0
more info

How to decode this binary message? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
When my best friend wrote his yearbook message to me in 5-bit binary, I didn't the slightest idea of how to translate it. Can anyone please tell me what he could have possibly said?
00001 01010 01101 00000 10001 11000 01010 10010 00111 00000 10001 00011.
-01001 00000 01010 00100 01100 00111 00000 00110 10010!
5 bit bcd with a=0 gives what initially looks like gibberish, though with a bit of playing around, you can pull out the phrase BINARY IS HARD. -JAKE MHAGS!, where MHAGS is presumably a misspelling of Jake's last name. Note that the educated guessing involved fixing numerous typos, inserting spaces, etc.
B K N A R Y K S H A R D J A K E M H A G S
Now in answer form instead of as a comment.