a simple functional queue