# How do I implement a Gap function I wrote in a gap cell in cloudsage?

I have written the following code in a cell:

```
%gap
OnChains:= function( c, g )
local i, k;
for i in [1..Length(c)] do
k[i] := OnSetsSets(c[i], g);
od;
return k;
end;
```

But when I try and run

```
G.orbit(Set(K[0]), action = "OnChains")
```

in a sage cell, I get:

```
Error in lines 1-1
Traceback (most recent call last):
File "/projects/b5d3c63b-a07d-41ae-905b-350044f6bb95/.sagemathcloud/sage_server.py", line 879, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "sage/misc/cachefunc.pyx", line 1896, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:11488)
w = self._cachedmethod._instance_call(self._instance, *args, **kwds)
File "sage/misc/cachefunc.pyx", line 2552, in sage.misc.cachefunc.CachedMethod._instance_call (build/cythonized/sage/misc/cachefunc.c:14934)
return self._cachedfunc.f(inst, *args, **kwds)
File "/projects/sage/sage-6.7/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.py", line 1208, in orbit
raise NotImplementedError("This action is not implemented (yet?).")
NotImplementedError: This action is not implemented (yet?).
```

Can someone help me implement my custom group action?

Help us help you: provide some complete minimal code. Give us G and K.

You need

`%gap`

in each cell with GAP code.Looks to me like the call

`G.orbit(Set(K[0]), action = "OnChains")`

is a Sage command which refers to some Sage to GAP interface, which implements only support for standard types of actions. If you want to use own`OnChains`

action, you may have to make a direct call of a GAP command (e.g.`Orbit(G, Set(K[0]), OnChains);`

) instead of using the Sage interface.