Advertisement
Guest User

Untitled

a guest
Apr 12th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.71 KB | None | 0 0
  1. let drawSquare count =
  2.     let rec square n =
  3.         let rec lineWithSpace index (str : string) =
  4.             match index with
  5.             |2 -> printfn "%A" <| "*" + str + "*"
  6.             |_ -> lineWithSpace (index - 1) (str.Insert(0," "))
  7.         let rec lineWithoutSpace index (str : string) =
  8.             match index with
  9.             |1 -> printfn "%A" <| str + "*"
  10.             |_ -> lineWithoutSpace (index - 1) (str.Insert(0,"*"))
  11.         match n with
  12.         |1 -> lineWithoutSpace count ""
  13.         |_ when n = count ->
  14.             lineWithoutSpace count ""
  15.             square (n - 1)
  16.         |_ ->
  17.             lineWithSpace count ""
  18.             square (n - 1)
  19.     square count
  20.  
  21. let draw = drawSquare 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement