Lesson 6 of 15

Functions

Functions

F# functions are defined with let. Parameters are space-separated — no parentheses or commas needed:

let add x y = x + y
let result = add 3 4
printfn $"{result}"  // 7

All F# functions are curried by default — applying fewer arguments than needed returns a new function:

let addFive = add 5   // partial application
printfn $"{addFive 3}"  // 8

Type Annotations (optional)

F# infers types, but you can be explicit:

let multiply (x: int) (y: int) : int = x * y

Your Task

Write a function area that takes width and height (both integers) and returns their product.

JS Transpiler loading...
Loading...
Click "Run" to execute your code.