Example: Python
def fib():
'''
a generator that produces the elements of the fibonacci series
'''
a = 1
b = 1
while True:
a, b = a + b, a
yield a
def nth(series, n):
'''
returns the nth element of a series,
consuming the earlier elements of the series
'''
for x in series:
n = n - 1
if n <= 0: return x print nth(fib(), 10)
Code from prettifier test_page.html
How to Google-Code-Prettify in Blogger:
1. Edit HTML template code, an add this two lines to head tag:
<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>
2. Add on the body tag onload="prettyPrint()", in case you have onload event used, add it in this way onalod="your actual code; prettyPrint()".
This is all!!
How to use it:
Put code snippets in <pre class="prettyprint">...</pre> or
<code class="prettyprint">...</code> and it will automatically be pretty printed.
Information extracted from Google Code Prettify Project.
No hay comentarios.:
Publicar un comentario