I see that one can take slices of lists, but is there any way to conditionally take a slice? For example, let's say I have this (fictitious) code: class FOO<list<string> names> { string First = names[0]; string Middle = !if(!eq(!length(names), 3), names[1], ""); string Last = !last(names); } Is there currently a way to implement this behavior or should I code up some new operators? -Dave
On May 8, 2009, at 5:18 PM, David Greene wrote:> I see that one can take slices of lists, but is there > any way to conditionally take a slice? > > For example, let's say I have this (fictitious) code: > > class FOO<list<string> names> { > string First = names[0]; > string Middle = !if(!eq(!length(names), 3), names[1], ""); > string Last = !last(names); > } > > Is there currently a way to implement this behavior or should I > code up some new operators?There isn't a good way to do this right now. Would it make more sense to add a high level operator that does what you want, instead of a bunch of primitives? -Chris
On Monday 11 May 2009 12:48, Chris Lattner wrote:> There isn't a good way to do this right now. Would it make more sense > to add a high level operator that does what you want, instead of a > bunch of primitives?That's what I'm looking into. -Dave