[Info-vax] ChatGPT - Joke about OpenVMS and Linux walking into a bar
Slo
slovuj at gmail.com
Sat Dec 31 16:03:33 EST 2022
> A suggestion: try asking it to do something with associative arrays in
> DCL and see what it comes up with. :-)
I asked for a recursion example in DCL and it showed this:
Recursion in DCL is a programming technique in which a function
or procedure calls itself repeatedly until a certain condition is met.
This allows for the repetition of a task without the need for a loop.
Here is an example of a DCL procedure that uses recursion to calculate the factorial of a number:
$! Declare the procedure and a variable to hold the result
$ procedure factorial
$ integer result
$! Check if the input number is 0 or 1
$ if $1 .eqs. 0 .or. $1 .eqs. 1 then
$ result = 1
$ else
$ ! Recursively call the procedure with the input number - 1
$ result = $1 * factorial($1 - 1)
$ endif
$! Return the result
$ return result
$! End the procedure
$ end
To use this procedure, you would simply call it with the number you want to find the factorial of
More information about the Info-vax
mailing list