Page 1 of 1

command line for "mod" or "rem"?

Posted: Mon Mar 25, 2013 9:10 pm
by pjthomas
This post may win the "most pedestrian" award. I'd like to add a curve to a plot of the form f(mod(t,period)) and I don't see a command equivalent to "mod" (or "rem") in the programmer's reference. The following works as a substitute:

atan2(sin(t*2*PI/period),cos(t*2*PI/period))

but that is a lot to type into the "plot what" dialog window, when all I really want is "mod(t,period)". Suggestions?

Re: command line for "mod" or "rem"?

Posted: Mon Mar 25, 2013 10:28 pm
by ted
You're looking for %.
for i=0,10 print i%3
It's in the NEURON Book, but not in Kernighan & Pike's original definition of hoc in "The UNIX Programming Environment," so you'll get a pass from them.

Re: command line for "mod" or "rem"?

Posted: Tue Mar 26, 2013 5:31 pm
by pjthomas
Many thanks, Ted! Sorry I didn't know that one -- it doesn't appear under the general "math" entry
http://www.neuron.yale.edu/neuron/stati ... .html#math

Re: command line for "mod" or "rem"?

Posted: Wed Mar 27, 2013 12:19 pm
by ted
I don't think any of the operators is listed in the Programmer's Reference--a stunning omission. We're doing a big rewrite of the Programmer's Reference, and this is one of the items on our to-do list.