AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Challenge: translate rosettacode - Was promoting autohotkey
Goto page Previous  1, 2, 3 ... 10, 11, 12
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
tidbit



Joined: 10 Mar 2008
Posts: 676
Location: USA

PostPosted: Tue Feb 02, 2010 5:33 pm    Post subject: Reply with quote

some things that have been done but not posted:
Loading 3D Animated Data & OpenGL --> http://de.autohotkey.com/forum/viewtopic.php?t=3977
Mandelbrot --> http://www.autohotkey.com/forum/viewtopic.php?t=43429
_________________
rawr. be very affraid
*poke*
Note: My name is all lowercase for a reason.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4517
Location: Boulder, CO

PostPosted: Tue Feb 02, 2010 6:08 pm    Post subject: Reply with quote

infogulch wrote:
I have issue with the current moving average code. The code itself is excellent; however, I think its not ideal for the purpose of rosettacode. Keeping static copies of the different values inside the function doesn't conform to the spirit of the objective imo, and is not universal (i.e. it couldn't be used in a library).
Well, you don't even need a function:
Code:
avg := i := 0
MsgBox % avg += (3-avg)/++i
MsgBox % avg += (8-avg)/++i
MsgBox % avg += (16-avg)/++i
MsgBox % avg += (53-avg)/++i
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 378

PostPosted: Tue Feb 02, 2010 6:24 pm    Post subject: Reply with quote

Laszlo wrote:
Well, you don't even need a function:
You are absolutely correct.
...

Actually:
Quote:
Create a stateful function/class/instance that takes a number as argument and returns a simple moving average of its arguments so far.
Note that the moving average has a period and numbers beyond the period must be dropped from the calculation of the average.

I didn't read the goal correctly, so I misinterpreted moving average for cumulative average. I don't have any issues anymore, sorry. Razz
_________________

Scripts
- License
Back to top
View user's profile Send private message
ih57452



Joined: 06 Feb 2010
Posts: 9

PostPosted: Sat Feb 06, 2010 6:17 pm    Post subject: Print a Multiplication Table Reply with quote

Print a Multiplication Table
Code:
SendMode, Input
Run, Notepad.exe,, Max
WinWaitActive, ahk_class Notepad
size = 12
x = 0
y = -1
Loop, % size + 2 {
   If (y = -1)
      Send, % format("X|")
   Else If (y = 0)
      Send, % format("|", "-")
   Else Send, % format(y . "|")
   Loop, %size% {
      x += 1
      If (y = -1)
         Send, % format(x)
      Else If (y = 0)
         Send, % format("", "-")
      Else If (x < y)
         Send, % format("")
      Else Send, % format(x * y)
   }
x = 0
y += 1
Send, {Enter}
}

format(str, fill = " ") {
   global size
   While, (StrLen(str) <= StrLen(size * size + 1))
      str := fill . str
   Return, str
}

I was trying to make the table look like the Perl example, but when I tried to put a "+" where the two lines intersected, my format() function apparently interpreted it as an operator instead of just a character in a string. I haven't figured out how to fix that yet, but a pipe will work. It works fine for the required 12x12 table, but turning it up to about 32x32 can cause some weird things to happen (looks like possibly a buffer getting filled up?). I've also considered making a version to display it in a AutoHotkey GUI and possibly another one to make it put the numbers into OpenOffice Calc.
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4517
Location: Boulder, CO

PostPosted: Sat Feb 06, 2010 7:47 pm    Post subject: Reply with quote

Nice! You can write it little shorter:
Code:
size = 24
Loop % size + 2 {
   t .= (y:=A_Index-2)<0 ? format("X|") : y=0 ? "`n" format("+", "-") : "`n" format(y . "|")
   Loop %size%
      t .= y<0 ? format(A_Index) : y=0 ? format("", "-") : A_Index<y ? format("") : format(A_Index * y)
}

Gui Font, s10, Courier New
Gui Add, Text,,%t%
Gui Show

format(str, fill = " ") {
   Global size
   VarSetCapacity(f, n:=StrLen(size*size)+1-StrLen(str), Asc(fill))
   Return SubStr(f,1,n) str
}
Back to top
View user's profile Send private message
tinku99



Joined: 03 Aug 2007
Posts: 312
Location: Houston, TX

PostPosted: Tue Feb 09, 2010 3:05 am    Post subject: bitmap storage tasks Reply with quote

I have fixed basic bitmap storage, read a ppm, and write a ppm using AutoHotkey_L45
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Goto page Previous  1, 2, 3 ... 10, 11, 12
Page 12 of 12

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group