+1kon wrote:Joystick position
Keyboard input/Keypress check
Musical scale
Nth
It's a shame that when Sobriquet was banned (for reasons unknown to me) that his/her existing posts were deleted also. It seems he/she has contributed quite a lot to Rosetta Code.
Rosetta Code
- smorgasbord
- Posts: 493
- Joined: 30 Sep 2013, 09:34
Re: Rosetta Code
John ... you working ?
Re: Rosetta Code
I wonder why too, maybe a mistake and now nobody know the reason, he posted some smart contributions in this thread.
Also, if you are curious, go to http://www.autohotkey.com/board/topic/1 ... torg-down/
Also, if you are curious, go to http://www.autohotkey.com/board/topic/1 ... torg-down/
Re: Rosetta Code
It is possible that he posted into a topic that was about to be nuked.
Recommends AHK Studio
Re: Rosetta Code
Awww man! This is not good.
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
- MasterFocus
- Posts: 146
- Joined: 01 Oct 2013, 09:47
- Location: Rio de Janeiro - RJ - Brasil
- Contact:
Re: Rosetta Code
To everyone (and in case someone knows Sobriquet, please let him know):
Some procedures to automatically deal with spam are currently being tested. His account may have been "pruned" by accident.
That's most certainly what happened. If possible, we will revert the changes (restoring the posts and his account).
Some procedures to automatically deal with spam are currently being tested. His account may have been "pruned" by accident.
That's most certainly what happened. If possible, we will revert the changes (restoring the posts and his account).
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
Re: Rosetta Code
Langton's ant could be fixed by d := d + !(a%x%_%y%) - !!(a%x%_%y%)jNizM wrote:Added first Post:
- AutoHotkey examples needing attention
Since I've been working on the problem, here's another solution (AHK 1.1) using some good ideas of the Aime code and CreateDIB() by SKAN:
Code: Select all
#NoEnv
SetBatchLines, -1
; Directions
Directions := {0: "North", 1: "East", 2: "South", 3: "West"}
; Initialize the plane (set all cells to white)
White := 0xFFFFFF
Plane := []
PW := PH := 100
Loop, % PH {
I := A_Index
Loop, % PW
Plane[I, A_Index] := White
}
; Let it run
DI := D := 0 ; initial direction
X := Y := 50 ; initial coordinates
While (X > 0) && (X <= PW) && (Y > 0) && (Y <= PH) {
D := (D + ((Plane[X, Y] ^= White) ? 1 : 3)) & 3
If (D & 1)
X += -(D = 3) + (D = 1)
Else
Y += -(D = 0) + (D = 2)
}
; Show the result
HBM := CreateDIB(Plane, PW, PH, 400, 400, 0)
Gui, Margin, 0, 0
Gui, Add, Text, x0 y0 w20 h440 Center 0x200, W
Gui, Add, Text, x20 y0 w400 h20 Center 0x200, N
Gui, Add, Picture, x20 y20 w400 h400 0x4E hwndHPIC ; SS_REALSIZECONTROL = 0x40 | SS_BITMAP = 0xE
DllCall("User32.dll\SendMessage", "Ptr", HPIC, "UInt", 0x172, "Ptr", 0, "Ptr", HBM) ; STM_SETIMAGE = 0x172
Gui, Add, Text, xp+5 yp h20 0x200 BackgroundTrans, % "Initial direction: " . Directions[DI]
Gui, Add, Text, x20 y420 w400 h20 Center 0x200, S
Gui, Add, Text, x420 y0 w20 h440 Center 0x200, E
Gui, Show, , Langton's ant (%PW%x%PH%)
Return
GuiClose:
ExitApp
CreateDIB(PixelArray, PAW, PAH, BMW := 0, BMH := 0, Gradient := 1) { ; SKAN, 01-Apr-2014 / array version by just me
SLL := (PAW * 3) + (PAW & 1)
VarSetCapacity(BMBITS, SLL * PAH, 0)
P := &BMBITS
Loop, % PAH {
R := A_Index
Loop, % PAW
P := Numput(PixelArray[R, A_Index], P + 0, "UInt") - 1
P += (PAW & 1)
}
HBM := DllCall("Gdi32.dll\CreateBitmap", "Int", PAW, "Int", PAH, "UInt", 1, "UInt", 24, "Ptr", 0, "UPtr")
HBM := DllCall("User32.dll\CopyImage", "Ptr", HBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008, "UPtr")
DllCall( "Gdi32.dll\SetBitmapBits", "Ptr", HBM, "UInt", SLL * PAH, "Ptr", &BMBITS)
If (!Gradient)
HBM := DllCall("User32.dll\CopyImage", "Ptr", HBM, "UInt", 0, "Int", 0, "Int", 0, "Int", 8, "UPtr")
Return DllCall("User32.dll\CopyImage", "Ptr", HBM, "UInt", 0, "Int", BMW, "Int", BMH, "UInt", 0x200C, "UPtr")
} ; http://ahkscript.org/boards/viewtopic.php?f=6&t=3203
Re: Rosetta Code
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: Rosetta Code
First-class functions
I believe that this should meet the requirements (but there might be better/easier solutions):
I believe that this should meet the requirements (but there might be better/easier solutions):
Code: Select all
#NoEnv
; Set the floating-point precision
SetFormat, Float, 0.15
; Super-global variables for function objects
Global F, G
; User-defined functions
Cube(X) {
Return X ** 3
}
CubeRoot(X) {
Return X ** (1/3)
}
; Function arrays, Sin/ASin and Cos/ACos are built-in
FuncArray1 := [Func("Sin"), Func("Cos"), Func("Cube")]
FuncArray2 := [Func("ASin"), Func("ACos"), Func("CubeRoot")]
; Compose
Compose(FN1, FN2) {
Static FG := Func("ComposedFunction")
F := FN1, G:= FN2
Return FG
}
ComposedFunction(X) {
Return F.(G.(X))
}
; Run
X := 0.5 + 0
Result := "Input:`n" . X . "`n`nOutput:"
For Index In FuncArray1
Result .= "`n" . Compose(FuncArray1[Index], FuncArray2[Index]).(X)
MsgBox, 0, First-Class Functions, % Result
ExitApp
Re: Rosetta Code
Added First-class functions by just me.
Also added:
Emirp primes
Extensible prime generator
Hello world/Newbie
I've started to work on Polymorphism as a way to learn about classes. I would appreciate some feedback and corrections before I post it to Rosetta Code.Edit: When the task description says "assignment" and "accessors", does it require a method like GetX() and SetX() or can it just be done with MyCircle.x := 2.
Also added:
Emirp primes
Extensible prime generator
Hello world/Newbie
I've started to work on Polymorphism as a way to learn about classes. I would appreciate some feedback and corrections before I post it to Rosetta Code.
Polymorphism - Task Description wrote:Create two classes Point(x,y) and Circle(x,y,r) with a polymorphic function print, accessors for (x,y,r), copy constructor, assignment and destructor and every possible default constructors
Code: Select all
MyCircle := new Circle(4, 7, 9)
MyCircle2 := MyCircle.Clone()
MyCircle.SetX(2)
MyCircle.SetY(3)
MyCircle.Print()
MyCircle2.Print()
MyCircle.SetX(100), MyCircle.SetY(1000), MyCircle.SetR(10000)
MsgBox, % MyCircle.GetX() "`n" MyCircle.GetY() "`n" MyCircle.GetR() "`n"
return
class Point
{
GetX()
{
return this.x
}
GetY()
{
return this.y
}
__New(x, y)
{
this.x := x
this.y := y
}
Print()
{
MsgBox, % "Point`n`nx:`t" this.x "`ny:`t" this.y
}
SetX(aValue)
{
this.x := aValue
}
SetY(aValue)
{
this.y := aValue
}
}
class Circle extends Point
{
GetR()
{
return this.r
}
__New(x, y, r)
{
this.r := r
base.__New(x, y)
}
Print()
{
MsgBox, % "Circle`n`nx:`t" this.x "`ny:`t" this.y "`nr:`t" this.r
}
SetR(aValue)
{
this.r := aValue
}
}
Re: Rosetta Code
I think that you could add two versions. AHK doesn't support private/protected properties and thus doesn't need assignment and accessor methods. On the other hand, the code posted above is corresponding to many samples of other languages. Maybe you might add a Copy() method returning This.Clone() this code.
Re: Rosetta Code
@just me thanks for the input and taking the time to look it over. I've posted it to Rosetta Code. I added a copy method as you suggested and also used your explanation:
Thanks again.
Instead of writing two versions of the task, I both included the assignment and accessor methods, and demonstrated directly accessing the properties also.AHK doesn't support private/protected properties and thus doesn't need assignment and accessor methods.
Thanks again.
Re: Rosetta Code
These are pretty simple. IBAN is the only one that's more than a handful of lines.
Generate lower case ASCII alphabet
IBAN
Read a file character by character/UTF8
Generate lower case ASCII alphabet
IBAN
Read a file character by character/UTF8
Re: Rosetta Code
good idea adding the machine code there!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Rosetta Code
Thanks joedf!
That task is still just a draft task. There seems to be some skepticism on the talk page regarding the usefulness of MCode. But MCode has been a valuable and powerful tool for AutoHotkey users.
That task is still just a draft task. There seems to be some skepticism on the talk page regarding the usefulness of MCode. But MCode has been a valuable and powerful tool for AutoHotkey users.
Re: Rosetta Code
Yeah, true.. There's two versions of the MCode() function that i know of..
Id say that the advantage of mcode is speed..
Id say that the advantage of mcode is speed..
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Rosetta Code
Agreed. Plus you can include all the code in the script itself.joedf wrote:Id say that the advantage of mcode is speed..
Re: Rosetta Code
You can also do low level tasks easier.joedf wrote:Yeah, true.. There's two versions of the MCode() function that i know of..
Id say that the advantage of mcode is speed..
Recommends AHK Studio
Return to “Off-topic Discussion”
Who is online
Users browsing this forum: No registered users and 54 guests