Simplifying the function and adding a docstring with an example:
def f(i, v1):
r"""
Return a copy of this list with elements of index `i` and `i + 1`
swapped.
EXAMPLE::
sage: l = [5, 4, 3, 2, 1, 0]
sage: f(3, l)
[5, 4, 3, 1, 2, 0]
"""
v = list(v1)
v[i], v[i+1] = v[i+1], v[i]
return v
Thanks to the docstring, one can now obtain the documentation
of the function with the usual question mark:
sage: f?
or the help function
sage: help(f)
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/2d61eb48-aab1-43d3-adba-6be8655ec2b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.