And on (and on (and on...))

  • Comments 1
  • Likes

So my journey of learning Monad continues, and I'm now in the realm of variables, functions and control flow.  On the UK student technology blog they have a play with MSH and come up with a version of the Fibonacci function (sorry if I spoilt the surprise guys :-p)  You can have a look at their post here:

I've rewritten their example as a recursive function in order to demonstrate some of the features of Monad.  In fact my example isn't quite the same since it terminates on printing the first number greater than 50, but the idea is similar.

function fib {
   param([int]$a, [int]$b)
   if($a -lt 50) { fib $b ($a+$b) }

MSH> fib 1 1

This demonstrates function and parameter defintion, output, conditionals and function calls.  Stay tuned for slightly more interesting stuff :-)

  • Nice - keep the handy hints coming :-)

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment