Jump to content

StringAPL UDF - Powerful calculations, Minimal code


minxomat
 Share

Recommended Posts

Hi there.

 

Abstract

 

This UDF enables the use of all reference APL features in AutoIt. Is uses the original APL symbols. The code is interpreted via a sandbox ngn-apl interface which relies on JavaScript. Execution is done via IE objects.

 

What's APL?

 

APL is a formal, imperative language. Because it is imperative, a sentence may be called an instruction, and may be executed to produce a result. StringAPL() has one main parameter, which is the APL source code. Thus:

 

 

StringAPL("2×(3+4)") = "14"

Unlike traditionally structured programming languages, code in APL is typically structured as chains of monadic or dyadic functions and operators acting on arrays. As APL has many nonstandard primitives (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or operator precedence.

 

The APL environment is called a workspace. In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program. For example,

 

 

StringAPL("N ← 4 5 6 7")

will initialize a vector "N" containing 4 elements according to the command. After each StringAPL call, the workspace is deleted completely, so you have to use multi-instructions if you want to reuse macros, functions or variables. Now that we have "N" we can manipulate it. Here's just a small example, you can do much more with APL (later more):

 

 

N+4

Will perform an addition. Every element in N is increased by (int)4. Easy, at least for now ;-)

 

What's possible?

 

Everything. If you feel like it, just draw a mandelbrot fractal using only one line 'o code. Or solve the n-Queen problem, or determine the first hundred prime numbers, or parse a html file. APL is like RegEx on crack. Some really advanced examples are included within the example file.

 

Now, why isn't APL more popular?

 

Because it uses a very, very strange charset. In fact, you have to install the APL Unicode font (https://sites.google.com/site/baavector/fonts) and set SciTe to use this font (CTRL+1 -> Change Monospace Font), before you can even view the examples! In addition to that, you scripts have to be UTF8 BOM encoded, which in return causes Au3Check to crash whenever custom includes are used. I'm planning on replacing the APL chrs with hum-readable english commands, but that may take some time :-)

 

Just look at the mandelbrot drawing code, it's absolutely ridiculous!:

apltestb773.png

 

I'd call it abstract art :D .

 

Examples

 

There are a few examples included. For the basic stuff please visit the Wikipedia APL page und Wikipedia APL reference:

 

examplese923.png

 

Remarks

 

Please do not use the second parameter yet, it is unfinished and experimental. Also, to use multiline-code, use . in-command to start a new line, just like the examples.

 

Download

 

Example file (INSTALL APL FONT AND ENCODE UTF8BOM!!!)

UDF (doesn't need any special treatment, doesn't contain APL chrs)

https://github.com/Perseus-Developers/StringAPL

 

Does not work in 3.3.9.5. Developed in 3.3.8.1. No further testing, please report bugs only if they occur in a stable version.

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Very nice!

You have all APL specific characters in the DejaVu Sans Mono (it is perfect for most fixed-pitch uses, e.g. editors).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I just reading about APL

here is some intresting links:

http://forum.apl2000.com/viewtopic.php?f=28&t=942

edit:

http://www.chilton.com/~jimw/setgame.html

edit2:

btw. works on 3.3.10.2 and 3.3.13.19

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Is that font really certified? I didn't try every single one, but most of them seem to have problems with some characters (such as downstile etc.). But if it works: great!

@mLipok Great tutorial here, too: http://www.jsoftware.com/papers/APLDictionary1.htm , also features a great reference.

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

One of my first freelance projects was on an IBM 5120 APL... Never worked with APL since but this is a good occasion to start learning the function set again, well if free time permits.

Anyway for those curious enough, this may add significant computing power to AutoIt. I wonder if it would be possible to skip html + IE and launch the .js directly.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

minx,

You're right. There are some functional symbols missing (represented by a thin square), at least in the version I have. I'll try to find a more complete version.

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Yes, you are right, the bottleneck is IE. Actually, you can spot a google.com tag in the code. This is to bypass the ActiveX filter. But the Site still has to go trough that filter. I think a 3rd party JS compiler will do the job.

Sadly, MS' ScriptControl stopped JS support at version 1.2, so this won't work.

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

minx,

I believe you should have mentionned "steepest_learning_curve_language_ever" in the keyword list of your post :mad2:

More seriously I checked the DejaVu site and the last snapshot has a version of DejaVu Sans Mono where all APL symbols defined in Unicode are available (and look correct AFAICT). I don't know which subset implemented in apl.js but that font should cover all practical uses.

I downloaded dejavu-fonts-ttf-2.34-20140118-2580.zip and all worked like a charm. I don't have the setup to compile from latest sources but it doesn't make a big difference for me: work in (slow) progress is on fixing kernings, adding ideographs I can't name and details that don't prevent me from sleeping well.

In SciTE I can see all these 70 APL symbols:

02336    ⌶    APL FUNCTIONAL SYMBOL I-BEAM
02337    ⌷    APL FUNCTIONAL SYMBOL SQUISH QUAD
02338    ⌸    APL FUNCTIONAL SYMBOL QUAD EQUAL
02339    ⌹    APL FUNCTIONAL SYMBOL QUAD DIVIDE
0233A    ⌺    APL FUNCTIONAL SYMBOL QUAD DIAMOND
0233B    ⌻    APL FUNCTIONAL SYMBOL QUAD JOT
0233C    ⌼    APL FUNCTIONAL SYMBOL QUAD CIRCLE
0233D    ⌽    APL FUNCTIONAL SYMBOL CIRCLE STILE
0233E    ⌾    APL FUNCTIONAL SYMBOL CIRCLE JOT
0233F    ⌿    APL FUNCTIONAL SYMBOL SLASH BAR
02340    ⍀    APL FUNCTIONAL SYMBOL BACKSLASH BAR
02341    ⍁    APL FUNCTIONAL SYMBOL QUAD SLASH
02342    ⍂    APL FUNCTIONAL SYMBOL QUAD BACKSLASH
02343    ⍃    APL FUNCTIONAL SYMBOL QUAD LESS-THAN
02344    ⍄    APL FUNCTIONAL SYMBOL QUAD GREATER-THAN
02345    ⍅    APL FUNCTIONAL SYMBOL LEFTWARDS VANE
02346    ⍆    APL FUNCTIONAL SYMBOL RIGHTWARDS VANE
02347    ⍇    APL FUNCTIONAL SYMBOL QUAD LEFTWARDS ARROW
02348    ⍈    APL FUNCTIONAL SYMBOL QUAD RIGHTWARDS ARROW
02349    ⍉    APL FUNCTIONAL SYMBOL CIRCLE BACKSLASH
0234A    ⍊    APL FUNCTIONAL SYMBOL DOWN TACK UNDERBAR
0234B    ⍋    APL FUNCTIONAL SYMBOL DELTA STILE
0234C    ⍌    APL FUNCTIONAL SYMBOL QUAD DOWN CARET
0234D    ⍍    APL FUNCTIONAL SYMBOL QUAD DELTA
0234E    ⍎    APL FUNCTIONAL SYMBOL DOWN TACK JOT
0234F    ⍏    APL FUNCTIONAL SYMBOL UPWARDS VANE
02350    ⍐    APL FUNCTIONAL SYMBOL QUAD UPWARDS ARROW
02351    ⍑    APL FUNCTIONAL SYMBOL UP TACK OVERBAR
02352    ⍒    APL FUNCTIONAL SYMBOL DEL STILE
02353    ⍓    APL FUNCTIONAL SYMBOL QUAD UP CARET
02354    ⍔    APL FUNCTIONAL SYMBOL QUAD DEL
02355    ⍕    APL FUNCTIONAL SYMBOL UP TACK JOT
02356    ⍖    APL FUNCTIONAL SYMBOL DOWNWARDS VANE
02357    ⍗    APL FUNCTIONAL SYMBOL QUAD DOWNWARDS ARROW
02358    ⍘    APL FUNCTIONAL SYMBOL QUOTE UNDERBAR
02359    ⍙    APL FUNCTIONAL SYMBOL DELTA UNDERBAR
0235A    ⍚    APL FUNCTIONAL SYMBOL DIAMOND UNDERBAR
0235B    ⍛    APL FUNCTIONAL SYMBOL JOT UNDERBAR
0235C    ⍜    APL FUNCTIONAL SYMBOL CIRCLE UNDERBAR
0235D    ⍝    APL FUNCTIONAL SYMBOL UP SHOE JOT
0235E    ⍞    APL FUNCTIONAL SYMBOL QUOTE QUAD
0235F    ⍟    APL FUNCTIONAL SYMBOL CIRCLE STAR
02360    ⍠    APL FUNCTIONAL SYMBOL QUAD COLON
02361    ⍡    APL FUNCTIONAL SYMBOL UP TACK DIAERESIS
02362    ⍢    APL FUNCTIONAL SYMBOL DEL DIAERESIS
02363    ⍣    APL FUNCTIONAL SYMBOL STAR DIAERESIS
02364    ⍤    APL FUNCTIONAL SYMBOL JOT DIAERESIS
02365    ⍥    APL FUNCTIONAL SYMBOL CIRCLE DIAERESIS
02366    ⍦    APL FUNCTIONAL SYMBOL DOWN SHOE STILE
02367    ⍧    APL FUNCTIONAL SYMBOL LEFT SHOE STILE
02368    ⍨    APL FUNCTIONAL SYMBOL TILDE DIAERESIS
02369    ⍩    APL FUNCTIONAL SYMBOL GREATER-THAN DIAERESIS
0236A    ⍪    APL FUNCTIONAL SYMBOL COMMA BAR
0236B    ⍫    APL FUNCTIONAL SYMBOL DEL TILDE
0236C    ⍬    APL FUNCTIONAL SYMBOL ZILDE
0236D    ⍭    APL FUNCTIONAL SYMBOL STILE TILDE
0236E    ⍮    APL FUNCTIONAL SYMBOL SEMICOLON UNDERBAR
0236F    ⍯    APL FUNCTIONAL SYMBOL QUAD NOT EQUAL
02370    ⍰    APL FUNCTIONAL SYMBOL QUAD QUESTION
02371    ⍱    APL FUNCTIONAL SYMBOL DOWN CARET TILDE
02372    ⍲    APL FUNCTIONAL SYMBOL UP CARET TILDE
02373    ⍳    APL FUNCTIONAL SYMBOL IOTA
02374    ⍴    APL FUNCTIONAL SYMBOL RHO
02375    ⍵    APL FUNCTIONAL SYMBOL OMEGA
02376    ⍶    APL FUNCTIONAL SYMBOL ALPHA UNDERBAR
02377    ⍷    APL FUNCTIONAL SYMBOL EPSILON UNDERBAR
02378    ⍸    APL FUNCTIONAL SYMBOL IOTA UNDERBAR
02379    ⍹    APL FUNCTIONAL SYMBOL OMEGA UNDERBAR
0237A    ⍺    APL FUNCTIONAL SYMBOL ALPHA
02395    ⎕    APL FUNCTIONAL SYMBOL QUAD
 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Then why bother downloading another font, when there is a more official fully-APL compatible font which is linked in the first post? I can't quite follow your logic there. For the testing of the symbols, just C&P the JSoftware Page I've linked (the last three tables contain the reference) and see if everything is the same. It is for the APL Unicode font (as expected).

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Because the APL fonts is not a good generic programming font and it doesn't contains characters for languages other than limited Latin, limited Greek and limited Cyrillic. It lacks diacritics, modifying letters, way too many symbols and much more. I don't want to have to switch fonts in SciTE so I prefer a "one size fits all" solution.

The advantage of DejaVu Sans Mono is that many of its glyphs have been specifically designed for programming, albeit I agree that APL functionnal symbols are much better rendered in APL385 than elsewhere.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...