$SPAD/src/input pascal.input

Timothy Daly December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool pascal.output
)set message test on
)set message auto off
)clear all

———-

This file shows some computations involving Pascal’s triangle — * —

--S 1 of 10
)set fun cache all
--R
--R   In general, interpreter functions will cache all values.
--E 1
--S 2 of 10
p(m,n | m=1)==1
--R
--R                                                                   Type: Void
--E 2
--S 3 of 10
p(m,n | m=n)==1
--R
--R                                                                   Type: Void
--E 3
--S 4 of 10
p(i,n | 1 < i and i < n) == p(i-1,n-1) + p(i,n-1)
--R
--R                                                                   Type: Void
--E 4
--S 5 of 10
p(2,3)
--R
--R   Compiling function p with type (Integer,Integer) -> PositiveInteger
--R   p will cache all previously computed values.

--R
--R   (4)  2
--R                                                        Type: PositiveInteger
--E 5
--S 6 of 10
pn(n) == [p(i,n) for i in 1..n]
--R
--R                                                                   Type: Void
--E 6
--S 7 of 10
pn(50)
--R
--R   Compiling function pn with type PositiveInteger -> List(
--R      PositiveInteger)
--R   pn will cache all previously computed values.
--R
--R   (6)
--R   [1, 49, 1176, 18424, 211876, 1906884, 13983816, 85900584, 450978066,
--R    2054455634, 8217822536, 29135916264, 92263734836, 262596783764,
--R    675248872536, 1575580702584, 3348108992991, 6499270398159, 11554258485616,
--R    18851684897584, 28277527346376, 39049918716424, 49699896548176,
--R    58343356817424, 63205303218876, 63205303218876, 58343356817424,
--R    49699896548176, 39049918716424, 28277527346376, 18851684897584,
--R    11554258485616, 6499270398159, 3348108992991, 1575580702584, 675248872536,
--R    262596783764, 92263734836, 29135916264, 8217822536, 2054455634, 450978066,
--R    85900584, 13983816, 1906884, 211876, 18424, 1176, 49, 1]
--R                                                  Type: List(PositiveInteger)
--E 7
--S 8 of 10
pk n == [pn(i) for i in 1..n]
--R
--R                                                                   Type: Void
--E 8
--S 9 of 10
pk 10
--R
--R   Compiling function pk with type PositiveInteger -> List(List(
--R      PositiveInteger))
--R   pk will cache all previously computed values.
--R
--R   (8)
--R   [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1], [1,5,10,10,5,1],
--R    [1,6,15,20,15,6,1], [1,7,21,35,35,21,7,1], [1,8,28,56,70,56,28,8,1],
--R    [1,9,36,84,126,126,84,36,9,1]]
--R                                            Type: List(List(PositiveInteger))
--E 9

———-

Reset the cache size — * —

--S 10 of 10
)set fun cache 10
--R
--R   In general, interpreter functions will cache the last 10 values.
--E 10
)spool
)lisp (bye)

———-

References^{[1] nothing}

6