new line char equal to (;)

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

new line char equal to (;)

Message par compsystems » mar. févr. 26, 2019 3:10 pm

Hello BP,

Copying the example

se:=(1,2,4,2)
li:=[se]
op(li)
nop(se)
nops(se)
%{se%}
size([se])
size(%{se%})
[enter] error

of 2.7 Listes, séquences, ensembles
https://www-fourier.ujf-grenoble.fr/~pa ... html#sec12
to work on the command entry, you have to add; at the end of each instruction

se:=(1,2,4,2);
li:=[se];
op(li);
nop(se);
nops(se);
%{se%};
size([se]);
size(%{se%});
[enter] ok

but within a program it is not obligatory either (;)

Code : Tout sélectionner

prg():={
	local se, li;
	se:=(1,2,4,2)
	print(se)
	li:=[se]
	print(li)
	print( op(li) )
	print( nop(se) )
	print( nops(se) )
	print( %{se%} )
	print( size([se]) )
	print( size(%{se%}) )
}
prg()[enter] ok

then Why in the entry line if it is required (;)?, I think that the new line char should be interpreted as end of sentence

on-line session Xcas

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: new line char equal to (;)

Message par compsystems » mer. févr. 27, 2019 2:26 pm

what I said before is not true, math expressions requires finishing with ( ; ) =(

Code : Tout sélectionner

function area_of_circle( ) 
begin 

	local Area, Radious; 

	ClrIO

	printf( "Please enter the radius of a circle" )
	input( Radious )

	Area := 3.14 * Radious ^ 2;  

	printf( "The area is %gen", Area )

	return Done

end

ok but without ;
Area := 3.14 * Radious ^ 2

(NULL)->
{ local Area,Radious;
ClrIO ;
printf("Please enter the radius of a circle");
input(Radious);
Area:=3.14*Radious^(2*printf("The area is %gen",Area)); // error =(
return(Done);
}

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: new line char equal to (;)

Message par parisse » jeu. févr. 28, 2019 6:47 am

Sometimes it's important to have newlines that are not equivalent to ;, like in programming structures.

Répondre