I am beginner of LaTeX, and wondering how to write functions or procedures in pseudocode. Is there any existing environment for that?
For what it's worth, I'm posting a summary of the comments as an answer.
There are several LaTeX packages for typesetting pseudocode. The most prominent are, in no particular order:
listings package also has an experimental feature called literate programming with similar goals.