M routines are added
This commit is contained in:
parent
5c6b89e337
commit
adcce06995
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
d hello^MyMath.m
|
||||||
|
|
||||||
|
r "Enter n: ",n,!
|
||||||
|
|
||||||
|
s areaCircle=$$areaCircle^MyMath.m(n)
|
||||||
|
w "areaCircle(",n,") = ",areaCircle,!
|
||||||
|
|
||||||
|
s fibonacci=$$fibonacci^MyMath.m(n)
|
||||||
|
w "fibonacci(",n,") = ",fibonacci,!
|
||||||
|
|
||||||
|
s factorialByVal=$$factorialByVal^MyMath.m(n)
|
||||||
|
w "factorialByVal(",n,") = ",factorialByVal,!
|
||||||
|
|
||||||
|
s m=n
|
||||||
|
do factorialByRef^MyMath.m(.n)
|
||||||
|
w "factorialByRef(",m,") = ",n,!
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
areaCircle(r)
|
||||||
|
q 3.1415926535898*r*r
|
||||||
|
|
||||||
|
factorialByRef(n)
|
||||||
|
i n=1 q
|
||||||
|
s k=1
|
||||||
|
f i=1:1:n d
|
||||||
|
. s k=k*i
|
||||||
|
s n=k
|
||||||
|
q
|
||||||
|
|
||||||
|
factorialByVal(n)
|
||||||
|
i n=1 q 1
|
||||||
|
s k=1
|
||||||
|
f i=1:1:n d
|
||||||
|
. s k=k*i
|
||||||
|
q k
|
||||||
|
|
||||||
|
fibonacci(n)
|
||||||
|
s f(1)=1,f(2)=1
|
||||||
|
f i=3:1:n d
|
||||||
|
. s f(i)=f(i-1)+f(i-2)
|
||||||
|
q f(n)
|
||||||
|
|
||||||
|
hello()
|
||||||
|
w "Hello!",!
|
||||||
|
q
|
47
README.md
47
README.md
|
@ -23,6 +23,10 @@ The examples in this tutorial are run with both GPL Mumps and GT.M.
|
||||||
|
|
||||||
- [MUMPS Technology Portal](http://mumps.cz/)
|
- [MUMPS Technology Portal](http://mumps.cz/)
|
||||||
|
|
||||||
|
### Additional Documentation
|
||||||
|
|
||||||
|
- [Sourceforge](http://mumps.sourceforge.net/)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quick Setup
|
## Quick Setup
|
||||||
|
@ -181,30 +185,7 @@ Copy the examples into your `~/.fis-gtm/V6.3-003A_x86_64/r` folder and run:
|
||||||
|
|
||||||
### [`ArraysShortened.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/ArraysShortened.m)
|
### [`ArraysShortened.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/ArraysShortened.m)
|
||||||
|
|
||||||
Approaching the solar system:
|
> The output obtained is the same as that in [`Arrays.m`](https://github.com/programarivm/mumps-examples/blob/master/01-the-very-basics/Arrays.m)
|
||||||
Mercury
|
|
||||||
Venus
|
|
||||||
Earth
|
|
||||||
Mars
|
|
||||||
Jupiter
|
|
||||||
Saturn
|
|
||||||
Uranus
|
|
||||||
Neptune
|
|
||||||
Pluto
|
|
||||||
|
|
||||||
September 2019:
|
|
||||||
26 27 28 29 30 31 1
|
|
||||||
2 3 4 5 6 7 8
|
|
||||||
9 10 11 12 13 14 15
|
|
||||||
16 17 18 19 20 21 22
|
|
||||||
23 24 25 26 27 28 29
|
|
||||||
30 1 2 3 4 5 6
|
|
||||||
|
|
||||||
Genealogical tree:
|
|
||||||
Harry and Emily had Jack
|
|
||||||
|
|
||||||
Associative array:
|
|
||||||
Have you ever been to London?
|
|
||||||
|
|
||||||
## 2. User Defined Functions
|
## 2. User Defined Functions
|
||||||
|
|
||||||
|
@ -223,9 +204,23 @@ Copy the examples into your `~/.fis-gtm/V6.3-003A_x86_64/r` folder and run:
|
||||||
Enter n: 9
|
Enter n: 9
|
||||||
F(9) = 34
|
F(9) = 34
|
||||||
|
|
||||||
## 3. Databases
|
## 3. Routines
|
||||||
|
|
||||||
### [`GenealogicalTree.m`](https://github.com/programarivm/mumps-examples/blob/master/03-databases/GenealogicalTree.m)
|
### [`Main.m`](https://github.com/programarivm/mumps-examples/blob/master/03-routines/Main.m)
|
||||||
|
|
||||||
|
Hello!
|
||||||
|
Enter n: 9
|
||||||
|
|
||||||
|
areaCircle(9) = 254.469
|
||||||
|
fibonacci(9) = 34
|
||||||
|
factorialByVal(9) = 362880
|
||||||
|
factorialByRef(9) = 362880
|
||||||
|
|
||||||
|
> For further details also visit [MyMath.m](https://github.com/programarivm/mumps-examples/blob/master/03-routines/MyMath.m)
|
||||||
|
|
||||||
|
## 4. Databases
|
||||||
|
|
||||||
|
### [`GenealogicalTree.m`](https://github.com/programarivm/mumps-examples/blob/master/04-databases/GenealogicalTree.m)
|
||||||
|
|
||||||
Genealogical tree:
|
Genealogical tree:
|
||||||
^gtree(0,1,1) is Jessica
|
^gtree(0,1,1) is Jessica
|
||||||
|
|
Loading…
Reference in New Issue