Constructing a simple tree with ASCII in F# This is just a basic HackerRank challenge I was working on to better understand F#. Its purpose is just to print a tree that has a straight 'trunk' of \$n\$, splits into 2 branches which diverge to \$n\$, then branches grow a straight trunk to \$\frac{n}{2}\$ which split and diverge to \$\frac{n}{2}\$, etc.

(Note: I was told to avoid using variables if possible, so the only one I used was to store the iterations which are meant to be \$n \le 5\$.)

[&lt;EntryPoint&gt;]
let main argv = 

    let iterations = System.Convert.ToInt32(System.Console.ReadLine())

    //63 rows
    //100 cols
    //16 length

    let splitRoots = fun x -&gt; Array.collect (fun elem -&gt; [|elem-1;elem+1|]) x

    let isEven = fun i -&gt; if i % 2 = 0 then true else false

    let advanceBranch = fun x -&gt; Array.mapi (fun i elem -&gt; if isEven i then elem-1 else elem+1) x

    let treeLine = fun oneLocs w -&gt; 
        String.concat "" (Seq.map (fun x -&gt; if Array.exists (fun elem -&gt; elem = x) oneLocs then "1" else "_") w)

    //if trunk and counter &gt; 0  --&gt;  write more trunk
    //if trunk and counter = 0 --&gt; split and transition to branch
    //if branch and counter &gt; 0 --&gt; write more branch
    //if branch and counter = 0 --&gt; transition to trunk and deecrement max
    let rec tree = fun l w h max original counter branch roots acc -&gt; 
        match branch with
        | _ when max = 0 -&gt; 
            acc
        | false when counter &gt; 0 -&gt; 
            tree l w h max original (counter-1) false roots (acc @ [ treeLine roots (seq { 1 .. w }) ])
        | false when counter = 0 -&gt; 
            tree l w h max original (original-1) true (splitRoots roots) acc
        | true when counter &gt; 0 -&gt;             
            tree l w h max original (counter-1) true (advanceBranch roots) (acc @ [ treeLine roots (seq { 1 .. w })])
        | true when counter = 0 -&gt;
            tree l w h (max-1) (original/2) (original/2) false roots (acc @ [ treeLine roots (seq { 1 .. w }) ])

    let emptyRow = String.concat "" (Seq.map (fun x -&gt; "_") (seq{ 1..100}))

    let makeEmptyRowList n = [1..n] |&gt; List.map (fun x -&gt; emptyRow)

    let fillList notFilled = (fun x -&gt; x @ (makeEmptyRowList (63-x.Length))) notFilled

    (tree 16 100 64 iterations 16 16 false [| 50 |] (List.empty))
        |&gt; fillList
        |&gt; List.rev 
        |&gt; List.iter (fun (x:string) -&gt; System.Console.WriteLine(x))

    0 // return an integer exit code
There's a couple of simple things you can do to reduce the clutter in your code. For example, this:

let isEven = fun i -&gt; if i % 2 = 0 then true else false


Firstly,

if someCondition then true else false


can always be written simply as

someCondition


You're also missing a trick with your declaration:

let someFunction = fun i -&gt; ...


Can simply be written as

let someFunction i = ...


So your isEven function is simply:

let isEven i = i % 2 = 0


I'm coming back to F# after a long break (2+ years) so I'm not going to suggest anything else as I'm still relearning!

Edit:

Actually... 

let emptyRow = String.concat "" (Seq.map (fun x -&gt; "_") (seq{ 1..100}))


Is simply:

 let emptyRow = String.replicate 100 "_"