[GAP Forum] Syntax error
dmitrii.pasechnik at cs.ox.ac.uk
dmitrii.pasechnik at cs.ox.ac.uk
Fri Jan 26 12:19:34 GMT 2018
Dear Angel,
On Fri, Jan 26, 2018 at 12:06:54PM +0000, dmitrii.pasechnik at cs.ox.ac.uk wrote:
> On Fri, Jan 26, 2018 at 12:24:33PM +0100, Angel Blasco wrote:
> > Dear forum, I'm a newbie user of GAP so this question maybe looks very
> > simple. I've written a function and saved it into a text file called
> > "ListaPrimos.g". I've tried to read it from GAP using Read command, and
> > this is the output message:
> >
> >
> > gap> Read("C:/gapListaPrimos/ListaPrimos.g");
> > Syntax error: expression expected in C:/gapListaPrimos/ListaPrimos.g line 1
> > ListaPrimos:=function(n)
> > ^
>
>
> It appears that you might have saved your function not as plain text,
> but as some kind of rich text format. (Thus you see that weird <feff>
> there)
more precisely, there is a Unicode character FEFF at the beginning of
the 1st line, which you might not see with editor in "rich-text" mode, but only
with a plain text editor (or in plain text mode).
http://www.fileformat.info/info/unicode/char/FEFF/index.htm
This character confused GAP.
As I compose this email in Vim, I see it as <feff>, but I don't see it
as I read the resulting email in my mail reader, so it's a bit
confusing, I know...
HTH
Dima
>
> Try saving it as plain text. (Perhaps in another editor...)
>
> As well, you might also want to add
>
> local primos, i;
>
> as the 2nd line (GAP likes local variables to be declared).
>
> HTH,
> Dima
>
> >
> >
> >
> > The function is:
> >
> > ListaPrimos:=function(n)
> > primos:=[];
> > for i in [1..n] do
> > if IsPrime(i) then
> > Add(primos,i);
> > fi;
> > od;
> > PrintTo("C:/primos.log",primos);
> > Print(primos);
> > Print(" Se han encontrado ",Length(primos)," primos entre 1 y ",n);
> > end;
> >
> > What is the expression expected?
> >
> > Regards
> > --
> > *Angel Blasco.*
> > _______________________________________________
> > Forum mailing list
> > Forum at gap-system.org
> > https://mail.gap-system.org/mailman/listinfo/forum
>
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum
More information about the Forum
mailing list