display of FunctionCalled(f)

1 view
Skip to first unread message

Ralf Hemmecke

unread,
Jun 22, 2024, 12:03:54 PMJun 22
to fricas-devel
According to

https://github.com/fricas/fricas/blob/master/src/algebra/variable.spad#L58

the argument f is a symbol. I think that the output function is not perfect.

coerce(r : %) : OutputForm == outputMapTran(f, r)$Lisp

It leads to

%%% (409) -> function(sin(x*y), 'g, 'x, 'y)

%%% (411) -> function(sin x, 'f, 'x)

(411) f
Type: Symbol
%%% (412) -> f

(412) f x == sin(x)
Type: FunctionCalled(f)

%(409) g
Type: Symbol
%%% (410) -> g

(410) g (x, y) == sin(x y)
Type: FunctionCalled(g)

What is OK for one argument (without parentheses), is not OK for two
arguments. There is a space between g and the open (. Of course, since
the OutputForm is wrong neither i-output.boo not the TeXFormat get it
right. TeX output looks like

g \ {\left( x, \: y \right)}\ == \ {\cos \left({{y+x}} \right)}

But there are also cases like this:

%%% (468) -> )clear prop g
%%% (468) -> g(n|n>1 and odd? n, t | t > 9) == tanh n + t
%%% (469) -> g

(469) g ((n, t) | n > 1 and odd?(n) and t > 9) == tanh(n) + t
Type: FunctionCalled(g)

whose corresponding OutputForm is this:
(CONCATB g
(PAREN (| (PAREN (AGGLST n t)) (and (and (> n 1) (odd? n)) (> t 9))))
== (+ (tanh n) t))

I guess, the definition of outputMapTran would have to be changed to
really produce just (f x) or (g x y) for the function application side
(left-hand side) in case that there is no conditional part.

I leave that to someone else.

Ralf

Waldek Hebisch

unread,
Jul 2, 2024, 9:48:21 PMJul 2
to fricas...@googlegroups.com
I think that we should put parentheses also around a single argument.
Then we can concat function name and arguments without space.

The result are like:

(16) foo(u) == exp(u)

(2) g((n, t) | n > 1 and odd?(n) and t > 9) == tanh(n) + t

(4) h(x, y) == sin(x y)

I think that is better than previous results containing space.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages