F# - Same Function With Different Parameters

Viewed 609

In F#, is it possible for a function to take one required parameter and one or more optional parametes depending on context? In the following toy example, whisk initially takes eggYolks as its only parameter but, in the very next step, it takes the output of the initial step plus granulatedSugar and marsalaWine. Is this possible and how do I feed the additional ingredients to tiramisu and print out both steps to the console?

module Tiramisu = 

// http://www.lihaoyi.com/post/WhatsFunctionalProgrammingAllAbout.html

open System

// Ingredients.    
let eggYolks = "70<g> of egg yolks."
let granulatedSugar = "100<g> of granulated sugar."
let marsalaWine = "120<ml> of sweet marsala wine."

let whisk ingredient = printf "Whisk %s\t" ingredient

let tiramisu ingredients =
    ingredients
    |> whisk // eggYolks only.
    // |> whisk // plus granulatedSugar and marsalaWine.

[<EntryPoint>]
tiramisu eggYolks
// tiramisu (eggYolks granulatedSugar marsalaWine)
1 Answers
Related