43 lines
867 B
Plaintext
43 lines
867 B
Plaintext
/* NetRexx ************************************************************
|
|
* 13.08.2013 Walter Pachl translated from REXX version 2
|
|
**********************************************************************/
|
|
options replace format comments java crossref savelog symbols nobinary
|
|
|
|
stk = create_stk
|
|
|
|
say push(stk,123) 'from push'
|
|
say empty(stk)
|
|
say peek(stk) 'from peek'
|
|
say pull(stk) 'from pull'
|
|
say empty(stk)
|
|
Say pull(stk) 'from pull'
|
|
|
|
method create_stk static returns Rexx
|
|
stk = ''
|
|
stk[0] = 0
|
|
return stk
|
|
|
|
method push(stk,v) static
|
|
stk[0]=stk[0]+1
|
|
stk[stk[0]]=v
|
|
Return v
|
|
|
|
method peek(stk) static
|
|
x=stk[0]
|
|
If x=0 Then
|
|
Return 'stk is empty'
|
|
Else
|
|
Return stk[x]
|
|
|
|
method pull(stk) static
|
|
x=stk[0]
|
|
If x=0 Then
|
|
Return 'stk is empty'
|
|
Else Do
|
|
stk[0]=stk[0]-1
|
|
Return stk[x]
|
|
End
|
|
|
|
method empty(stk) static
|
|
Return stk[0]=0
|