How to define a Multiplication table with a new binary operation on a set In GAP? (1). I am trying to define a new binary operation on a given group in GAP. But I could not find any help. If anyone can help me with some reference or code, it would be great. 
(2). I have constructed the table with a new operation on a group using the code:
gap> g:=SymmetricGroup(3);
Sym( [ 1 .. 3 ] )
gap> f:=function(g, x, y);
> if x in Set(g) and y in Set(g) then
> return y^-1 * x * y^2;
> fi;
> end;
function( g, x, y ) ... end
gap> M:=List(g, x-> List(g, y-> f(g, x, y)));;

But the problem I am facing is that M is a table but it does not show as the multiplication table. I need the multiplication table so that I can construct a loop from it. Thanks in advance.
 A: First, I will reproduce your initial setup:
gap> g:=SymmetricGroup(3);
Sym( [ 1 .. 3 ] )
gap> f:=function(g, x, y);
> if x in Set(g) and y in Set(g) then
> return y^-1 * x * y^2;
> fi;
> end;
function( g, x, y ) ... end

Note that you can check membership in a group using x in g more efficiently. Also, perhaps you want some action of the condition does not hold (an error message?). Anyway, in your setting you call it with the right arguments.
What you need to do to create a table is to use positions of group elements in the fixed list of its elements, rather than elements themselves:
gap> elts:=AsSSortedList(g);
[ (), (2,3), (1,2), (1,2,3), (1,3,2), (1,3) ]
gap> T:=List(g, x-> List(g, y-> Position(elts,f(g, x, y))));
[ [ 1, 2, 6, 5, 4, 3 ], [ 2, 1, 4, 2, 2, 5 ], [ 6, 5, 1, 6, 6, 4 ], 
  [ 5, 6, 3, 4, 1, 2 ], [ 4, 3, 2, 1, 5, 6 ], [ 3, 4, 5, 3, 3, 1 ] ]
gap> Display(T):
[ [  1,  2,  6,  5,  4,  3 ],
  [  2,  1,  4,  2,  2,  5 ],
  [  6,  5,  1,  6,  6,  4 ],
  [  5,  6,  3,  4,  1,  2 ],
  [  4,  3,  2,  1,  5,  6 ],
  [  3,  4,  5,  3,  3,  1 ] ]
gap> M:=MagmaByMultiplicationTable(T);
<magma with 6 generators>
gap> IsAssociative(M);
false
gap> IsCommutative(M);
false

If you want to construct a loop, try the LOOPS package. I have tried that with the T above, following examples here, but the table does not define a loop:
gap> LoadPackage("loops");
─────────────────────────────────────────────────────────────────────────────
Loading  loops 3.4.1 (The LOOPS Package: Loops and quasigroups for GAP)
by Gábor Nagy (http://www.math.u-szeged.hu/~nagyg/) and
   Petr Vojtěchovský (http://www.math.du.edu/~petr/).
Homepage: https://gap-packages.github.io/loops/
Report issues at https://github.com/gap-packages/loops/issues
─────────────────────────────────────────────────────────────────────────────
true
gap> IsLoopTable(T);
false
gap> IsQuasigroupTable(T);
false

