nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libevent: rename `bind_to` to the more precise `bind_tcp`
[nit.git]
/
examples
/
fibonacci.nit
diff --git
a/examples/fibonacci.nit
b/examples/fibonacci.nit
index
0df0209
..
50b93be
100644
(file)
--- a/
examples/fibonacci.nit
+++ b/
examples/fibonacci.nit
@@
-14,23
+14,20
@@
# See the License for the specific language governing permissions and
# limitations under the License.
# See the License for the specific language governing permissions and
# limitations under the License.
-# A simple exemple of refinement where a method is added to the integer class.
-package fibonacci
+# Simple example of refinement where a method is added to the integer class.
+module fibonacci is example
redef class Int
# Calculate the self-th element of the fibonacci sequence.
redef class Int
# Calculate the self-th element of the fibonacci sequence.
- meth fibonacci: Int
+ fun fibonacci: Int
do
do
- if self < 2 then
- return 1
- else
- return (self-2).fibonacci + (self-1).fibonacci
- end
- end
+ if self < 2 then return self
+ return (self-2).fibonacci + (self-1).fibonacci
+ end
end
# Print usage and exit.
end
# Print usage and exit.
-meth usage
+fun usage
do
print "Usage: fibonnaci <integer>"
exit 0
do
print "Usage: fibonnaci <integer>"
exit 0