1 people like it.

Alternative Conditional Printfn

A different approach to conditional debug functions

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
let dbgFunction d = 
    printfn "[Beginning debug operation]"

    printfn "test %d" d

    printfn "[Debug operation complete]"

let stndFunction d = 
    printfn "test %d" d    
    
let printft v d = 
    if v < 3 then stndFunction d
    else dbgFunction d
    
printft 2 148418
printft 3 148418
val dbgFunction : d:int -> unit

Full name: Script.dbgFunction
val d : int
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val stndFunction : d:int -> unit

Full name: Script.stndFunction
val printft : v:int -> d:int -> unit

Full name: Script.printft
val v : int
Raw view New version

More information

Link:http://fssnip.net/55
Posted:6 years ago
Author:David Klein
Tags: debug