Does APL2 allow functions to return functions, or is that strictly the province of experimental APLs like NARS2000 and extended-beyond-the-standards APLs like Dyalog?
@JeffZeitlin ah ok, didn't mean to be pedantic; but if I may, even then operators don't really return functions
from my experiences with trying to do functional programming in APL, I think operators are "closer" to being "functions who might take functions as arguments" than to being "functions who return functions"
@JeffZeitlin nvm, I don't need Haskell for this :P if you look closely at any operator you write, you always call the functions you define inside the operator
sure; imagine you wanted to write an op that expects a monadic function and that returns the "square" of that function, i.e. the function applied after itself
In defining _Dup you still have to explicitly use the arguments, so it is more of a type of currying than actually returning functions. I.e. *_Dup feels somewhat like doing 2∘+
but hey, I'd love Dyalog APL to be able to return functions from operators
I hope I was able to get my point across; I haven't mastered this aspect of APL so I won't be able to argue much further :P
The reason I'm asking is because I'm looking to hack an "enhancement" into the IBM5110 emulator I've pointed to before, to allow "changing diskettes". To do that, I need to be able to write a variable to disk, and read it back into memory, and it's got to be treated as a BLOB, a pure sequence of bytes.
I'm not sure how to do that; I can probably figure out how to "hook" it to (a local copy of) the page code; it's the actual load/save that I don't have.
what exactly is it that you are asking about? how to create BLOBs? where to save those BLOBs? how to gather everything that exists in the session and how to restore those later on?
The emulator allows me to )LOAD and )SAVE workspaces (and the equivalent in BASIC), but the disk images that I'm loading from or saving to are strictly in memory. I'm looking to be able to write those images to disk and read them back. They're stored in variables, so I need to be able to write the variable into a host disk file, and read the file back into the variable. I don't need to be able to "merge" the data on disk with the extant disk image in memory, or anything like that.
@JeffZeitlin so let me see if I get this correctly: you'd like a button you could push and it would download to your computer a file with the workspace; smth you could send my by email. I'd then be able to press another button that would open, say, a file explorer; I would navigate to the file you sent me and be able to load your saved session into the emulator; is that it?
In GWBASIC, it would more-or-less be the equivalent of BSAVE diskfile,PTR(variable),LEN(variable), where diskfile is the file on disk, and variable is the variable in which the disk image is held.
More or less, yes.
But not a workspace, per se, a "diskette" with one or more files on it.
IOW, in the emulator, I )SAVE WS1, work more )SAVE WS2, then push the button; the file created is a disk image with both WS1 and WS2 in it.
@JeffZeitlin (@RGS) Neither APL2 nor NARS2000 allows returning a function. And Dyalog only allows it from tradfns/tradops, though it is an undocumented feature/bug.