 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Trikster
Joined: 15 Jul 2007 Posts: 1224 Location: Enterprise, Alabama
|
Posted: Tue Oct 30, 2007 2:09 am Post subject: nado() (2.0) |
|
|
Ok, as I was in Math Class today I was working some problems that had to do with some variables: n, a, and d. It was very annoying to have to work out all of the steps. So I made up a function for it. Via nado() (the variables of the function put together.)
| Code: | nado(n, a, d, ByRef OutputVar)
{
OutputVar := a+(n-1)*d
}
|
Examples:
| Code: | nado(5, 2, 3, Equation) ; 14
MsgBox,, Answer, %Equation%
nado(1567, 57, 78, Equation) ; 12205
MsgBox,, Answer, %Equation% |
Post feedback, please.
Update: v2.0:
Thanks to engunneer, I now have a more responsible method of using this function:
| Code: | nado(n, a, d)
{
Return a+(n-1)*d
} |
Example:
| Code: | | MsgBox,, Answer, % nado(1,3,5) ; 3 |
Last edited by Trikster on Tue Oct 30, 2007 2:26 am; edited 2 times in total |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Tue Oct 30, 2007 2:19 am Post subject: |
|
|
a more "standard" way of doing this would be
| Code: |
nado(n, a, d)
{
Return a+(n-1)*d
}
|
| Code: |
Equation := nado(1,3,5)
|
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Trikster
Joined: 15 Jul 2007 Posts: 1224 Location: Enterprise, Alabama
|
Posted: Tue Oct 30, 2007 2:20 am Post subject: |
|
|
I know of this method of well, whatever you call it. And I tried it earlier without any success with yours, or my own code used.
Edit: Never mind, I got it to work by changing the example to the following:
| Code: | | MsgBox,, Answer, % nado(1,3,5) | Thanks. |
|
| Back to top |
|
 |
steliyan
Joined: 20 Apr 2007 Posts: 31
|
Posted: Tue Oct 30, 2007 6:30 am Post subject: |
|
|
| I guess you're talking about arithmetic progression? |
|
| Back to top |
|
 |
Trikster
Joined: 15 Jul 2007 Posts: 1224 Location: Enterprise, Alabama
|
Posted: Tue Oct 30, 2007 3:08 pm Post subject: |
|
|
| I belive so, I'm in second block right now. I can find out in a sec. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|