0
votes

I just started working on F# and tried running a basic program but the output is coming out to be wrong.

Earlier it was showing error "error FS0010: Incomplete structured construct at or before this point in binding" but right now it's just showing ;; on terminal. I am running the code real-time using FSI: Send line.

Code: ->

let prep prefixStr baseStr = 
   prefixStr + ", " + baseStr

prep "Hello" "Mohit"
1
your code itself is correct. > val prep : prefixStr:string -> baseStr:string -> string val it : string = "Hello, Mohit" Just select the whole region and send it with Alt+Enter. What is the editor you're using? - s952163

1 Answers

2
votes

When using F# Interactive, you need to send it complete valid blocks of F# code. A single line (function header) that is followed by the body is not a valid block. If you send the first line of your code, the editor sees:

let prep prefixStr baseStr = 

It complains because this is incomplete. Better way of working is to highlight the whole function definition and then use FSI: Send Selection with selection being:

let prep prefixStr baseStr = 
   prefixStr + ", " + baseStr

This will define the function. After that, you can run the last line using either FSI: Send Selection or using FSI: Send Line because this is a stand-alone valid expression:

prep "Hello" "Mohit"