Invalid args findAll(|sys::V,sys::Int->sys::Bool|), not (|sys::Int->sys::Bool|) ERROR: cannot compile script
Thanks in advance, Casper
brianTue 5 Aug 2008
Casper,
There isn't a convenience method on Range to go to a List, although I'll add a Range.toList method for next build. Until then you need to do something like:
list := Int[,]
(30..35).each |Int i| { list.add(i) }
Regarding the map issue - it is because without any other explicit type declaration, the result of map will be Obj[], not Int[]. You can fix with this code:
mrmorris Tue 5 Aug 2008
How do I go from a range to a list of values:
range := /[30..35]/ // Does not amount to /[30,31,32,33,34,35]/
Also, what's the reason the following mapping can not be chained to a filter:
fahrenheitTemps := /[30,31,32,33,34,35/] celciusTemps := fahrenheitTemps.map(Int[,]) |Int v->Int| { return (5/9)*(v-32) } frozen := celciusTemps.findAll( |Int v->Bool| { return v < 32 } )
Invalid args findAll(|sys::V,sys::Int->sys::Bool|), not (|sys::Int->sys::Bool|) ERROR: cannot compile script
Thanks in advance, Casper
brian Tue 5 Aug 2008
Casper,
There isn't a convenience method on Range to go to a List, although I'll add a
Range.toList
method for next build. Until then you need to do something like:Regarding the map issue - it is because without any other explicit type declaration, the result of
map
will beObj[]
, notInt[]
. You can fix with this code:However findAll should work against
Obj[]
just fine according to newly defined rules. That is something I still need to fix. See previous discussion.mrmorris Wed 6 Aug 2008
Thank you very much Brian. Continue the great work! :)
Casper