[GAP Forum] concat strings and define methods

Frank Lübeck Frank.Luebeck at math.rwth-aachen.de
Fri Sep 23 07:04:42 BST 2005


On Wed, Sep 21, 2005 at 05:48:13AM +0900, Park Won-Kyu wrote:
> I found the Concatenation("a","b") function but, can I define method like as
> 
> "a"+"b", "a"+1 ?
> 
> and is it possible to use [1,2]^(1,2) as "List([1,2],i->i^(1,2));" ?
> 
> Please let me know how can i find related documentations or hints

Dear Park Won-Kyu, dear Forum,

It is possible, to install methods for expressions as above, as you could
see in an answer by Stefan Kohl. (I also don't know, what you have in mind
with "a"+1.)

But I don't recommend to do so:

If you define
    "a" + "b"
to return 
    Concatenation("a", "b")
it becomes too easy to produce inefficient GAP input or code, like
    str := "a";
    [...]
    str := str + "b";
(instead of 'Append(str, "b")' which does not copy the previous content)
or
    str := "a" + "b" + "c" + "d";
(which GAP would understand as
    str := Concatenation(Concatenation(Concatenation("a","b"),"c"),"d");
which is much worse than 'str := Concatenation("a","b","c","d")'.)


For '[1,2]^(1,2)' use the very efficient function 'OnTuples', see the
documentation.

As I see at least two "natural" meanings for 'list^permutation', namely
'Permuted' or 'OnTuples' (if the entries of the list are positive integers)
I would not use the syntax the syntax you asked about but use the functions
provided by GAP to keep your input easier to understand.

Best regards,
  Frank Luebeck

-- 
///  Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Templergraben 64,  ///
\\\                    52062 Aachen, Germany                          \\\
///  E-mail: Frank.Luebeck at Math.RWTH-Aachen.De                        ///
\\\  WWW:    http://www.math.rwth-aachen.de/~Frank.Luebeck/           \\\





More information about the Forum mailing list