Sunday, 15 May 2011

math - Swift enum recursive associated value -



math - Swift enum recursive associated value -

i'm trying create math look using enumeration in swift. enumeration can constant, associated value of type complexnumber (a simple struct). can square root expression, recursive associated value. example, want able store sqrt(sqrt(1+2i)) in enum.

enum look { case sqrt(expression) case constant(complexnumber) }

xcode (6 beta 2) crashes immediately. what's problem? read in swift guide associated values, should work.

now possible swift 2.0 since beta 4. examples taken release notes:

enum list<t> { case nil indirect case cons(head: t, tail: list<t>) } indirect enum tree<t> { case leaf(t) case branch(left: tree<t>, right: tree<t>) }

math recursion enums swift

No comments:

Post a Comment