Maple V5 to Maple 18 - How to create a list of variables? - maple

I used Maple V5 back in 92 to write some functions to solve some problems using Groebner basis. Since then I have used Maple for simple calculations and therefore my programming skills are long-forgotten. Most of the functions I wrote and used at that time no longer work and I am trying to go back and update them to the Maple Version I currently have, that is, Maple 18.
Questions:
a) Is there an automatic tool to update old Maple functions?
b) Commands such as vars := [x.(1 .. n)] used to work but not anymore. The ideia was to create a list with x1,x2,.. xn. I know that seq(x[i], i = 1 .. 5) would create a list with x_1,x_2, ... but it is not exactly the same.
c) Tips and suggestions how to smooth out the process of updating are most welcome.
Thanks
Ed

The command that you're looking for is
vars:= [x||(1..n)];
Maple V 5 was released in 1997. Almost all documented commands available in that release still work today. The current version in '92 was Maple V. The current version today is Maple 2016, not Maple 2018. I'm not aware of any automatic update tool.
Let me know if you need more code translated.

There were some changes to the language between Maple V Release 5 and Maple 6, and the replacement of . with || was one of those.
Maple 6 (and 7 if I recall) shipped with an additional binary updtsrc which could act on Maple source files and make the text replacements. For example, if I start with a plaintext file var.mpl containing just this,
vars := [x.(1 .. n)];
and then apply the shell command updtsrc var.mpl I get this output,
`.` has been replaced by `||`; see ?||
vars := [x||(1 .. n)];
I did that on Ubuntu 14.04.4 LTS Linux, using the (redhat) updtsrc binary downloaded from the HTTP link for Linux on this page.
If your Maple V sources are in a .mws worksheet file then you might have to export the input to a plaintext file.
I haven't tried in (on a plaintext file, in a DOS window, or Powershell) on MS-Windows (though the zip file from that page did unpack to a updtsrc.exe file).
So if you have a great deal of old codes containing language incompatibilities between Maple V and Maple 6 then you could try this route to automate the conversion.
There have been some commands deprecated betwen Maple 6 and Maple 18 (eg, lowercase vector) but few further language changes (backwards incompatibilities).
I suggest that you read the help pages in your Maple 18 for the language updates. In particular I suggest you look at the help pages for these help topics (entering these in the Help Brower's Search bar):
updtsrc
updates,Maple6,compatibility
As for you second example involving vector, it is true that vector has been deprecated and superceded by the Vector command.
But even in MapleV R5 you should not really have been using op(f) on vector f. More correct would have been eval(f) or evalm(f). Eg,
f:=vector([-x1^2,x2*u]);
[ 2 ]
f := [-x1 , x2 u]
var:=u;
var := u
subs(var=cat(var,0), eval(f));
[ 2 ]
[-x1 , x2 u0]
Now, suppose you instead use Vector in the above. In that case using op(f) in that subs call will produce the error you cited, because unlike vector the Vector beast does not have last-name-eval.
f:=Vector([-x1^2,x2*u]);
[ 2]
f := [-x1 ]
[ ]
[x2 u]
var:=u;
var := u
subs(var=cat(var,0), op(f));
Error, invalid input: subs received 2, which is not valid for
its 2nd argument
You could still use eval(f) here, but in fact it is not necessary.
subs(var=cat(var,0), eval(f));
[ 2 ]
[-x1 ]
[ ]
[x2 u0]
subs(var=cat(var,0), f);
[ 2 ]
[-x1 ]
[ ]
[x2 u0]
Lastly, try to download and install the point-release Maple 18.02 rather than stick with Maple 18.00. You can find that here.

Related

How to get Linting in VSCode for Julia

I think Julia is a great Language, but I find that there is a total lack of any error detection in VsCode.
Look at this code example:
I would expect that red squiggly lines show up in these places:
StructABCNotDefined is not a valid type
|> operator not defined for Integers
Should not be able to call fun with a String as an argument
fun does not return something of type StructABCNotDefined
Without proper type checking working it's a total mess like python only that it runs a bit faster. What am I doing wrong? Is it possible to setup VsCode to have these type checking abilities for Julia?
The Julia VSCode extension highlights at least some of your issues.
Note that linting is only active when the Julia file is inside a workspace (see https://github.com/julia-vscode/julia-vscode/issues/1105).
With JET.jl more issues can be identified:
julia> #report_call fun(5)
═════ 2 possible errors found ═════
┌ # c:\Users\d90394\Downloads\Untitled-1.jl:2 NonExistingStruct
│ `Main.NonExistingStruct` is not defined
└─────────────────────────────────────────────
┌ # c:\Users\d90394\Downloads\Untitled-1.jl:2 n |> 2
│┌ # operators.jl:911 f(x)
││ no matching method found `(::Int64)(::Int64)`: f::Int64(x::Int64)
│└────────────────────

Is it still possible to programme in LISP 1/1.5?

All of the resources online I find are for Common Lisp, even when I try to search specifically for original LISP resources. I suspect that Common is probably a lot easier, but I thought it might be fun to try Lisp out from the beginning of it's history as a language.
Yes, and it's easy in fact. This person has a tarball which lets you run Lisp 1.5 on the SIMH emulator for the IBM 7094, which must have, I think, been the system Lisp 1.5 was ported to from the 704 (the 7094 is a transistor machine, the 704 was valve (tube)). Here is a link to the slides from a talk given by Norman Richards at the March 2015 Clojure meetup where he must have demonstrated all this working.
Example
I did this on a scratch Ubuntu 20.04 machine.
Get SIMH, with aptitude install simh or whatever you are using.
Get the above tarball and unpack it.
unpack the utils-1.1.8.tar.gz tarball inside it and build txt2bcd;
put txt2bcd somewhere in your PATH;
profit.
The tarball includes a factorial program, inevitably, and here's a transcript of it running:
ts$ i7094 lisptape.ini factorial.txt
IBM 7094 simulator V3.8-1
MTA: unit is read only
MTA: unit is read only
LPT: creating new file
HALT instruction, PC: 10524 (TRA 10523)
Goodbye
ts$ cat sys.log
TEST FACTORIAL
THE TIME ( 0/ 0 000.0) HAS COME, THE WALRUS SAID, TO TALK OF MANY THI
NGS ..... -LEWIS CARROLL-
EVALQUOTE OPERATOR AS OF 1 MARCH 1961. INPUT LISTS NOW BEING READ.
THE TIME ( 0/ 0 000.0) HAS COME, THE WALRUS SAID, TO TALK OF MANY THI
NGS ..... -LEWIS CARROLL-
FUNCTION EVALQUOTE HAS BEEN ENTERED, ARGUMENTS..
DEFINE
(((FACTORIAL (LAMBDA (X) (COND ((EQUAL X 0) 1) (T (TIMES X (FACTORIAL (
SUB1 X)))))))))
END OF EVALQUOTE, VALUE IS ..
*TRUE*
FUNCTION EVALQUOTE HAS BEEN ENTERED, ARGUMENTS..
FACTORIAL
(10)
END OF EVALQUOTE, VALUE IS ..
3628800
THE TIME ( 0/ 0 000.0) HAS COME, THE WALRUS SAID, TO TALK OF MANY THI
NGS ..... -LEWIS CARROLL-
END OF EVALQUOTE OPERATOR
FIN END OF LISP RUN
So it's that easy: I was amazed, having spent much longer than this trying to get MACLISP to run. I think later systems are harder because they assume terminal types and so on as there is more interactivity.
Some other links
Some other links which might be useful (some from my original comment):
a listing of Lisp 1.5 for (I presume) the IBM 7094);
an IBM 704 emulator for Windows if you wanted to go even further back;
The SIMH software kits list lists Lisp for the PDP-1, which is what is described here and which is also very early.

Converge (fixed point) syntax difference in q and k

We should use square brackets when flattering all levels in list:
q)b:(1 2;(3 4;5 6);7;8)
q)raze/[b] / flatten all levels
1 2 3 4 5 6 7 8
q)raze/b
'/
[0] raze/b
But why one forced to use raze/[b] for Converge syntax instead of simple raze/b?
Upd
Why this syntax works in k, for example {x+y}/1 2 3 but doesn't work in q?
My assumption that it's been made to prevent qbies errors when using / adverb instead of %. I think there may be a discussion about it in some dev channel, but I've found only Shakti discussion group for now at https://groups.google.com/forum/#!forum/shaktidb, and kx.com also shutted down community wiki, so I don't know where to find an additional info - asking here
Upd2
The / is quite overloaded in k too: see (not official ref though) https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md#over - over, fixedpoint, for and while. Pretty the same as in q, right? But why the interpreter 'ban' the k syntax in q context, - is there a technical reason why q can't recognise a user intention as it k does?
The reason that, say, cos/1 works in k but not q is that q has no ambivalence. That is to say that all q operators are not overloaded on valence, as noted in section 6.1.2 in q4m.
With any of q's adverbs (each:', over:/ scan:\, prior::, eachright:/:, eachleft:\:) the resulting derivative function is interpreted by q to be dyadic, unless you uses []'s to specifically pass one argument.
For the example above q interprets cos/ as do rather than converge and so requires the left argument specifying the number of iterations (Note the results of 0 cos/ 1, 1 cos/ 1, 2 cos/ 1, etc.). The preferred way to resolve is to use []'s: cos/[1].
(cos/) 1 works because user defined functions can never use infix notation, so the expression is automatically interpreted as applying monadically. This is also why 2 (cos/) 1 fails. To resolve this you would again have to use []'s: (cos/)[2;1].
You don't necessarily need square brackets here. You could use
(raze/)b
if you do not want to use square brackets around b. The way you are using over ( or /) without the brackets around b requires the parenthesis around raze/b if you do not specify the initial value of the accumulator. This is because the q interpreter needs to know that you are applying raze/ to the list b rather than applying / to the list first (which is why a '/ error is thrown) then raze after (reading the code from right to left).
More info on using / can be found here: https://code.kx.com/q4m3/6_Functions/#676-over-for-accumulation

Programming in QuickBasic with repl.it?

I'm trying to get a "retro-computing" class open and would like to give people the opportunity to finish projects at home (without carrying a 3kb monstrosity out of 1980 with them) I've heard that repl.it has every programming language, does it have QuickBasic and how do I use it online? Thanks for the help in advance!
You can do it (hint: search for QBasic; it shares syntax with QuickBASIC), but you should be aware that it has some limitations as it's running on an incomplete JavaScript implementation. For completeness, I'll reproduce the info from the original blog post:
What works
Only text mode is supported. The most common commands (enough to run
nibbles) are implemented. These include:
Subs and functions
Arrays
User types
Shared variables
Loops
Input from screen
What doesn't work
Graphics modes are not supported
No statements are allowed on the same line as IF/THEN
Line numbers are not supported
Only the built-in functions used by NIBBLES.BAS are implemented
All subroutines and functions must be declared using DECLARE
This is far from being done. In the comments, AC0KG points out that
P=1-1 doesn't work.
In short, it would need another 50 or 100 hours of work and there is
no reason to do this.
One caveat that I haven't been able to determine is a statement like INPUT or LINE INPUT... They just don't seem to work for me on repl.it, and I don't know where else one might find qb.js hosted.
My recommendation: FreeBASIC
I would recommend FreeBASIC instead, if possible. It's essentially a modern reimplementation coded in C++ (last I knew) with additional functionality.
Old DOS stuff like the DEF SEG statement and VARSEG function are no longer applicable since it is a modern BASIC implementation operating on a 32-bit flat address space rather than 16-bit segmented memory. I'm not sure what the difference between the old SADD function and the new StrPtr function is, if there is any, but the idea is the same: return the address of the bytes that make up a string.
You could also disable some stuff and maintain QB compatibility using #lang "qb" as the first line of a program as there will be noticeable differences when using the default "fb" dialect, or you could embrace the new features and avoid the "qb" dialect, focusing primarily on the programming concepts instead; the choice is yours. Regardless of the dialect you choose, the basic stuff should work just fine:
DECLARE SUB collatz ()
DIM SHARED n AS INTEGER
INPUT "Enter a value for n: ", n
PRINT n
DO WHILE n <> 4
collatz
PRINT n
LOOP
PRINT 2
PRINT 1
SUB collatz
IF n MOD 2 = 1 THEN
n = 3 * n + 1
ELSE
n = n \ 2
END IF
END SUB
A word about QB64
One might argue that there is a much more compatible transpiler known as QB64 (except for some things like DEF FN...), but I cannot recommend it if you want a tool for students to use. It's a large download for Windows users, and its syntax checking can be a bit poor at times, to the point that you might see the QB code compile only to see a cryptic message like "C++ compilation failed! See internals\temp\compile.txt for details". Simply put, it's usable and highly compatible, but it needs some work, like the qb.js script that repl.it uses.
An alternative: DOSBox and autorun
You could also find a way to run an actual copy of QB 4.5 in something like DOSBox and simply modify the autorun information in the default DOSBox.conf (or whatever it's called) to automatically launch QB. Then just repackage it with the modified DOSBox.conf in a nice installer for easy distribution (NSIS, Inno Setup, etc.) This will provide the most retro experience beyond something like a FreeDOS virtual machine as you'll be dealing with the 16-bit segmented memory, VGA, etc.—all emulated of course.

In Emacs: how to reference latex equation in text by its number .dvi?

Suppose, I use Emacs to write a function in latex:
\begin{equation}
\label{eq:myeq}
x=2y
\end{equation}
that gives me
x = 2y (1)
in a resulting .dvi. And suppose I have dozens of such equations. Here is the problem: if I have to reference this equation but don't remember its name I want to be able to reference it by it's number ((1) in the shown case).
The story. Actually, I know there is an emacs package that has such a function. Like this: I press key combination, the function asks me to enter an equation number and returns it's name, nicely surrounded by (\ref{ and }). I used it, but after changing OS on my computer I've lost that Emacs installation. And now I don't remember what was the name of that package I once installed. Or maybe it was just a function in .emacs. Googling by key words gives RefTex, but I didn't found that feature in RefTex. So if someone uses that incredible package - please tell me its name!
Found the following package:
http://www.emacswiki.org/emacs/download/AuxLabel
Make sure to read the LIMITATIONS section.