mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merged with upstream. Updated M (aka MUMPS) detection to use the new bayesian / samples method.
This commit is contained in:
42
samples/M/dynamicscoping.m
Normal file
42
samples/M/dynamicscoping.m
Normal file
@@ -0,0 +1,42 @@
|
||||
;------------------------------------
|
||||
; These first two routines illustrate
|
||||
; the dynamic scope of variables in M
|
||||
;------------------------------------
|
||||
triangle1(x) ;;
|
||||
set sum=0
|
||||
for do quit:x'>1
|
||||
. set sum=sum+x
|
||||
. set x=x-1
|
||||
quit sum
|
||||
|
||||
main1() ;;
|
||||
set sum=1500
|
||||
set x=6
|
||||
write "sum before=",sum,!
|
||||
set y=$$triangle1(x)
|
||||
write "sum after=",sum,!
|
||||
write "triangle of ",x," is ",y,!
|
||||
quit
|
||||
|
||||
|
||||
;------------------------------------
|
||||
; These next two routines illustrate
|
||||
; the use of the NEW command to make
|
||||
; variables limited to the local scope
|
||||
;------------------------------------
|
||||
triangle2(x) ;;
|
||||
new sum ; <-- HERE !!
|
||||
set sum=0
|
||||
for do quit:x'>1
|
||||
. set sum=sum+x
|
||||
. set x=x-1
|
||||
quit sum
|
||||
|
||||
main2() ;;
|
||||
set sum=1500
|
||||
set x=6
|
||||
write "sum before=",sum,!
|
||||
set y=$$triangle2(x)
|
||||
write "sum after=",sum,!
|
||||
write "triangle of ",x," is ",y,!
|
||||
quit
|
||||
Reference in New Issue
Block a user