defining functions and index in PostgreSQL :   I have 2 questions in Postgres:

1-	How can I define(create) these functions?
-	AnyElement(s): which returns any element.
-	FirstElement(s): which returns the first element.
-	lastElement(s): which returns the last element. 
-	ithElement(s): which returns the ith element.
-	currentElement(s): which returns current element.

2-	How can I define(create) index?
