Skip to content

Complaints about missing System.Globalization assembly #9

@vilinski

Description

@vilinski

The following code brings the compiler error:

Compilation failed.
(22,8)-(22,13) The type referenced through 'System.Globalization.CultureInfo' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Globalization'.
printfn "Hello, world!"

let mul a b = a * b

let a = 42
let b = 2
let c = mul a b
printfn "%i * %i = %i" a b c

type Calculation =
    | Literal of int
    | Mul of Calculation * Calculation
    | Plus of Calculation * Calculation
    | Minus of Calculation * Calculation

let rec eval calc = 
    match calc with
    | Literal i -> i
    | Mul(a,b) -> eval a * eval b
    | Plus(a,b) -> eval a + eval b
    | Minus(a,b) -> eval a - eval b
let rec print calc =
    match calc with
    | Literal i -> string i
    | Mul(a,b) -> sprintf "(%s * %s)" (print a) (print b)
    | Plus(a,b) -> sprintf "(%s + %s)" (print a) (print b)
    | Minus(a,b) -> sprintf "(%s - %s)" (print a) (print b)
let calc = Mul(Minus(Plus(Literal 42, Literal 2), Literal 1), Literal 3)

printfn "eval %A = %i" (print calc) (eval calc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions