|Newbie questions about Pliant
Sample of a simple Pliant program
|Message posted by maybe Marcus on 2002/04/17 15:08:20
I wonder if you could send me a sample of a standalone Pliant program (.pli)
which gets the number from the user (using keyboard_input, or the like),
computes the recursive factorial (or any other mundane function), and
presents the result on the console.
Since I am going to use this sample to ilustrate Pliant's basic language
constructs, it would be nice if the program uses one global variable and one
|Message posted by maybe Patrice Ossona de Mendez on 2002/04/17 15:26:30
# define the factorial function
function fact n -> f
arg Int n f
f := 1
for (var Int i) 1 n
f *= i
# ask for a number and parse the answer to get global variable 'number'
(keyboard_input "Give me a number ") eparse (gvar Int number)
# print the result of the call of 'fact'
console "Factorial is " fact:number eol
|Message posted by maybe Marcus on 2002/04/17 18:48:37