1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Function that recursively allocate and concatenate strings.
17 # It is related to the Fibonacci sequence since:
19 # * `strfib(0).length == 0`
20 # * `strfib(1).length == 2`
21 # * `strfib(n).length = strfib(n-1).length + strfib(n-2).length + 2`
22 fun strfib
(i
: Int): String
24 if i
== 0 then return ""
25 if i
== 1 then return "()"
26 return "({strfib(i-2)}{strfib(i-1)})"
30 if args
.has
("-q") then
36 if args
.length
> 0 then n
= args
.first
.to_i