The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
syntax flexibility (programming) of xcas on HP-Prime
02-08-2019, 09:23 PM (This post was last modified: 02-09-2019 02:01 PM by compsystems.)
Post: #1
syntax flexibility (programming) of xcas on HP-Prime
Hello, HP-Prime users, the syntax flexibility of xcas makes you like it a lot, some users according to the context they like, at the beginning and at the end of the blocks with symbols {...}, others in a more explicit way is to say for example to define a function with words, Func..EndFunc

According to the following set of definitions, Xcas supports 8 different ways to define a function, it is not governed by a particular style, of course the compilation is done in ~ c++
PHP Code:
/// c++ style
f1) := 

  
local k;
  
:= 5;
  return 
k
}; 

f2) :=
begin  
  local k
;
  
:= 5;
  return 
k
end;

function 
f3)
begin  
  local k
;
  
:= 5;
  return 
k
end;

function 
f4)
  
local k;
  
:= 5;
  return 
k
ffunction

function 
f4a)
  
local k;
  
:= 5;
  return 
k
end

f5 := function( 
  
local k;
  
:= 5;
  return 
k
end

// Pascal style
function f6)
begin  
  
var k;
  
:= 5;
  return 
k
end;

// TI68k (ti89 tiv200) style
:f7)
:
Func
:  Local k
:  5 → k
:  Return k
:EndFunc

// python style
// ... 

result of compilation
PHP Code:
nameFunction 
(x)-> 
local k
k:=5;  
return(
x*k);  


test
f1(3); f2(3); f3(3); f4(3); f5(3); f6(3); ClrIO [enter] returns 15, 15, 15, 15, 15, 15

test online
Different ways to define a function.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
syntax flexibility (programming) of xcas on HP-Prime - compsystems - 02-08-2019 09:23 PM



User(s) browsing this thread: 1 Guest(s)