-
Notifications
You must be signed in to change notification settings - Fork 1
Lamed
Paul Lipkowski edited this page Dec 9, 2023
·
38 revisions
Lamed (v.0.5.2) is an upcoming version of RPN Calculator (now Papaj), which was released on December 18, 2021. It is named after the twelfth letter of Hebrew alphabet – lamed (ל).
- Name: Lamed
- Version Code: 0.5.2
- Version Type: Generation 3 build
- Release Date: December 18, 2021
- Stable precedessor: Khaf (v.0.5.1)
- Stable successor: Mem (v.0.5.3)
- Language: FreePascal
- Lines of code: 13720
- Number of functions: 530 + user-defined ones
- Maximum number of instructions: de facto no limit (depends how many you can put in AnsiString, which has limit of either 2,147,483,647 (32 bit) or 9,223,372,036,854,775,807 chars (64 bit))
- Number of entity types: 9 (10 with quasitypes)
- Number of packages: 6
- Tested on:
- systems: Windows (2000, Vista, 7, 8.1, Win10), Linux (Ubuntu, Debian, Manjaro)
- architectures: i386/x86 (32 bit), amd64/x64 (64 bit)
- all changes included in the updates of 0.5.1
- Packages now require
@use()
to be used. - Rebuild of console app core
- Reintroduction of flags
- for-each const loop
- syntax rework – RPN does not require spaces between
()
,[]
and{}
– allow e.g.if (true) {true}
- Note that it does not apply between
}{
,)(
,][
–if(true){true}
is not allowed
- Note that it does not apply between
-
Vanilla functions:
-
shl
,shr
numsort
-
callWhile
,callUntil
-
swapAt
,swapAt2
-
- GUI Application:
- Extended language support: Afrikaans, Croatian, French, Dutch, German, Macedonian, Norwegian, Portuguese, Russian, Serbian, Slovene, Swedish
- More advanced file management
- Source code window and output window are resizable
- Switch that allows the output window be cleared after each run or not
- Ability to run script in an external terminal window
- Allow
$t $f filter
with functions instead of logical expressions (for $t being either array or string) - Allow
$t $f cut
with functions instead of logical expressions (for $t being either array or string) -
Array package functions:
cut
-
cutZeros
,cutEmptyStrings
,cutNulls
-
distinctNumbers
,distinctStrings
,distinct
reduceStdDev
-
first
,last
crushBy
-
pad
,padRight
,padLeft
,padEntities
,padEntitiesRight
,padEntitiesLeft
,padSpaces
,padSpacesRight
,padSpacesLeft
,padNulls
,padNullsRight
,padNullsLeft
,padZeros
,padZerosRight
,padZerosLeft
,padEmptyStrings
,padEmptyStringsRight
,padEmptyStringsLeft
randomFrom
-
reduceGCD
,reduceLCM
sort
-
trim
,trimLeft
,trimRight
,trimNulls
,trimNullsRight
,trimNullsLeft
,trimEntities
,trimEntitiesRight
,trimEntitiesLeft
-
Date package functions:
-
isInRange
,isDateInRange
,isTimeInRange
addWeek
-
-
Math package functions:
-
arcsec
,arccsc
-
sgn
/sign
– sign function - inverse hyperbolic functions –
arsinh
,arcosh
,artanh
,arcoth
,arsech
,arcsch
-
moment
,quantile
-
tertile
,quartile
,octile
,decile
,hexadecile
,percentile
- Beta distribution functions:
distBeta
,funcBeta
,randomBeta
,genBeta
- Fisher-Snedecor (F) distribution functions:
distF
,funcF
,randomF
,genF
-
factorize
,primeDistribution
,leastPrimeDivisor
-
randomIntRange
,randomRealRange
-
euclidean
and its aliasbezoutCoefs
-
erf
,erfc
-
fomega
,fOmega
(andcountDistinctFactors
,countAllFactors
as aliases) -
fLiouville
andfLambda
as alias isSquareFree
-
-
String package functions:
-
padChars
,padCharsRight
,padCharsLeft
-
trimChars
,trimCharsRight
,trimCharsLeft
-
quoted
,apostrophed
,enclosed
map
-
reduce
,reduceLeft
,reduceLeftFromFirst
,reduceRight
,reduceRightFromLast
-
filter
,cut
-
first
,last
-
delete
,copies
,divide
,removeMatching
,translate
-
compare
,isEmpty
-
- Move
String.system
toConsole.system
-
Console package functions:
-
delay
(for Unix) -
UserName
,UserHome
HostName
-
OSName
,OSDistribution
(and its aliasOSDist
),OSVersion
-
CPUBits
,CPUArchitecture
(and its aliasCPUArch
) -
UserShell
(for Unix only)
-
- Directives of
@fixprecision(X)
,@maxprecision(X)
- Arithmetics on strings
- rebuild fit for variables
- Runtime params rebuild
- fix bugs and errors
- "." bug
- multidimensional arrays issue
- arrays in arrays issue
- T distribution bug
- fix
String.quoted
bug - fix quotes parsing bug
- fix
Array.getAt
andString.getAt
bug - fix xdg-terminal bug
- add mate-terminal support
- add functions:
String.quoted2
,String.apostrophed2
- fix if-else bug with entities instead of instruction blocks
- add functions:
Math.coprimes
,Math.modularPower
,Math.modPower
,Math.modPow
,Math.modularInverse
,Math.modularMulInverse
,Math.modMulInv
,Math.isCarmichael
- add item index in for-each loop –
for ( index item : $T )
andfor ( const index item : $T )
- add Unix scripts support (shebangs)
- add script that installs rpn to
/bin
for all users
Examples of code of version 0.5.2
- Hello world
"Hello world!" println
- Factorial (different methods)
// using recursive function
function {
>n
if ( n 0 = ) {
1
} else {
n n -- factorial *
}
} >factorial
scan toNumber factorial
// using stack-aggregating function "seq"
scan toNumber 1 1 seq
all product
// using Math package
@uses(Math)
scan toNumber factorial
- Fibonacci sequence (different methods)
// using times-loop
function {
>n
if ( n 0 = ) {
0
} elif ( n 1 = ) {
1
} else {
// put 2 initial values we will add up
0 1
n -- times {
// duplicate the values and create a sum
2 copy +
// remove the LHS value: reverse 3 elements, remove the last one and order them back
3 rev rem swap
// so now we have a RHS value and the added one as the new values to sum
// and so on n-2 more times
}
swap rem
}
} >fib
scan toNumber fib
// using classical for-loop
function {
>n
if ( n 0 = ) {
0
} elif ( n 1 = ) {
1
} else {
// put 2 initial values we will add up
0 1
for ( 2 -> i ; i n <= ; i ++ -> i ) {
// duplicate the values and create a sum
2 copy +
// remove the LHS value: reverse 3 elements, remove the last one and order them back
3 rev rem swap
// so now we have a RHS value and the added one as the new values to sum
// and so on up to i <= n
}
swap rem
}
} >fib
scan toNumber fib
// using Math package
@use(Math)
scan toNumber fibonacci
- Checking if there is a person more stupid than Forrest Gump in a group of N people using normal distribution
@silent
@use(Math)
@use(String)
@use(Array)
"Enter the population size: " print
scan toNumber -> n
[ $n 100 15 genNorm ] reduceMin -> m1
"Sample's Lowest IQ: " $m1 toString concat println
"Forrest Gump's IQ: 70" println
- Sorting an array
// sorting an array with 10 random integers from a range [0..99]
@use(Array)
[ 10 times { 100 random } ] sortNumbers println
// sorting a user-defined array
// without double exclamation at push, making it return the new array that is later assigned to a variable
@use(Array)
@use(String)
"Set array length: " print
scan toNumber -> n
[] -> T
1 -> i
n times {
"Push the " i toString ". element: " 2 times concat print
T scan toNumber push -> T
i ++ -> i
}
T sortNumbers println
// sorting a user-defined array
// with double exclamation at push, making it act like a procedure
@use(Array)
@use(String)
"Set array length: " print
scan toNumber -> n
[] -> T
1 -> i
n times {
"Push the " i toString ". element: " 2 times concat print
T scan toNumber push!!
i ++ -> i
}
T sortNumbers println
- Dirichlet Convolution
// computing Dirichlet's convolution of 1/n and sin(n) in a point defined by user
// using basic sum through array elements
@use(Math)
function { -1 ^ } -> f
function { sin } -> g
function {
>k >g >f
0 -> sum
for ( $i : [ $k genNaturalDivisors ] ) {
$i f $k $i div g * $sum + -> $sum
}
$sum
} -> DirichletConvolve
scan toNumber -> $n
$f $g $n DirichletConvolve
// computing Dirichlet's convolution of 1/n and sin(n) in a point defined by user
// using array mapping and reducing
@use(Math)
@use(Array)
function { -1 ^ } -> f
function { sin } -> g
function {
>k >g >f
[ $k genNaturalDivisors ]
fun{ >i
$i f $k $i div g *
} map
reduceSum
} -> DirichletConvolve
scan toNumber -> $n
$f $g $n DirichletConvolve
// computing Dirichlet's convolution of 1/n and sin(n) in a point defined by user
// using array mapping and reducing
// with 0.5.2 features
@use(Math)
@use(Array)
function { inv } -> f
function { sin } -> g
function (f g k) {
[$k genNaturalDivisors]
fun{ >i
$i f $k $i div g *
} map
reduceSum
} -> DirichletConvolve
scan toNumber -> $n
$f $g $n DirichletConvolve
Versions of Papaj:
Pre-builds: Bereshit (v.0.0.1), Shemot (v.0.0.2)
Aleph (v.0.1.0), Bet (v.0.2.0), Gimel (v.0.2.1), Dalet (v.0.3.0)
Hey (v.0.3.1), Vav (v.0.4.0), Zain (v.0.4.1), Chet (v.0.4.2), Tet (v.0.4.3)
Yod (v.0.5.0), Khaf (v.0.5.1), Lamed (v.0.5.2), Mem (v.0.5.3), Nun (v.0.5.4), Samech (v.0.5.5)
Development version: Leviathan
Packages of Papaj:
Vanilla, Array, Console, Date, Math, Number, String
Structures of Papaj:
Conditional, Entity, Loop, Variable
Array, Boolean, DateTime, Exception, LogicalExpression, Function, Number, Null, String
Home, PapajScript, Papaj (interpreter), Papaj REPL