Can I pass a function as an argument in Verse? Are functions first class citizens?

   So yes it can be done while I didn't find this in the documentation about                                      
   functions.  It tho follows from the fact that everything in the Verse is                                
   an expression so you can use anything as a parameter

  

    ```
    var BaseNum : int = 100
   
    #substract 1 from integer
    Sub1(x:int):int =
        x - 1
    
    #Takes as an argument function with signature Int->Int and an integer  
    EatTheFunction(IntToInt(x:int):int, Num : int) : int = 
        IntToInt(Num) #feeds Num as an argument
    
    OnBegin<override>()<suspends>:void=
       Print("BaseNum is {BaseNum}") #prints 100
       Print("{EatTheFunction(Sub1,BaseNum)}") #prints 99
     ```
8 Likes