Skip to content

RealArray in functor #17

@ellerh

Description

@ellerh

This example

functor Foo (val update : RealArray.array * int * real -> unit) =
  struct
    val foo = update
  end

structure Foo = Foo (val update = RealArray.update);

val a = RealArray.array (3, 2.0)
val _ = (Foo.foo (a, 1, 1.0);
       if Real.== (RealArray.sub (a, 1),  1.0) then print "OK\n"
       else print ("WRONG (" ^ Real.toString (RealArray.sub (a, 1)) ^ ")\n"))

when executed with: mlworks -tty -no-init < test.sml
prints

MLWorks 2.1 Professional Edition
Copyright (C) 1999 Harlequin Group plc.  All rights reserved.
MLWorks is a trademark of Harlequin Group plc.

MLWorks> MLWorks>> MLWorks>> MLWorks>> MLWorks>> MLWorks>> functor Foo
structure Foo =
  struct
    val foo : (RealArray.array * int * real) -> unit = fn
  end
MLWorks> MLWorks> MLWorks>> MLWorks>> MLWorks>> MLWorks>> WRONG (7.9892357038E~312)
val a : RealArray.array = #F[2.0, 7.989235704E~312, 2.0]

the expected result is of course #F[2.0, 1.0, 2.0]

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