[Ifeffit] Ifeffit "print" command question
Matt Newville
newville at cars.uchicago.edu
Fri Dec 31 13:31:40 CST 2010
Hi Tony, Bruce,
Like Bruce said, Ifeffit is a pretty poor excuse for a general purpose
calculator shell program. Sadly, the documentation Bruce pointed
turns out to be wrong....
The print function is pretty awful to use. It was inspired by bash &
perl, but is much worse.The actual behavior is / appears to be:
- strings inside single quotes are not evaluated
- strings inside double quotes are evaluated.
- spaces in an unquoted string confuse "print", appearing to mean
separate items to be evaluated.
The general Ifeffit behavior is to "keep going in spite of errors" and
so it will spit out piles of zeros rather than tell you what the
problem is. Again, it's a poor excuse of a shell program.
Whereas the documentation says
print "7 * sqrt(99.11) = ", (7 * sqrt(99.11))
What you really want is one of these
print '7 * sqrt(99.11) = ', (7*sqrt(99.11))
print '7 * sqrt(99.11) = ', "(7 * sqrt(99.11))"
For your question,
print " the square root of ", number, " is ", sqrt(number)
should be
print ' the square root of ', number, ' is ', sqrt(number)
although, just for safety, I would recommend
print ' the square root of ', "number", ' is ', "sqrt(number)"
as it allows an expression with spaces:
Ifeffit> number = 19
Ifeffit> print 'the square root of ', number, ' is ', "sqrt(number)"
the square root of 19.0000000 is 4.35889894
Ifeffit> print 'the square root of ', "number + 1", ' is ', "sqrt(number + 1)"
the square root of 20.0000000 is 4.47213595
Sorry for the confusion, the lame shell, and the poor documentation.
OK, I have a New Year's Resolution: make larch/ifeffit2 usable!
--Matt
More information about the Ifeffit
mailing list