[GAP Forum] concat strings and define methods

Stefan Kohl kohl at mathematik.uni-stuttgart.de
Thu Sep 22 11:11:08 BST 2005


Dear Forum,

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

What you can easily do is to install your own methods
for these purposes, e.g.:

InstallOtherMethod( \+, "for two strings", ReturnTrue,
                     [ IsString, IsString ], 0,
                     function ( s1, s2 ) return Concatenation(s1,s2); end );

InstallOtherMethod( \^, "for list and permutation", ReturnTrue,
                     [ IsList, IsPerm ], 0,
                     function ( l, perm ) return Permuted(l,perm); end );

However, I do not know what you think "a"+1 should return.

Hope this helps,

     Stefan Kohl

---------------------------------------------------------------------------
Stefan Kohl
Institut für Geometrie und Topologie
Pfaffenwaldring 57
Universität Stuttgart
70550 Stuttgart / Germany

E-mail: kohl at mathematik.uni-stuttgart.de
Web:    http://www.cip.mathematik.uni-stuttgart.de/~kohlsn/
---------------------------------------------------------------------------







More information about the Forum mailing list