Description
i am facing a problem
can any one help me with this problem
//collect all of the odd values in a array recursion
main() {
print(collectoddValues([1,2,3,4,5,6,7,89]))
;}
collectoddValues( arr) {
var result = [] ;
helper(helperInput) {
if (helperInput.length == 0) {
return 0;
}
if (helperInput[0] % 2 != 0) {
result.insert(helperInput, [0]);
}
return helper(helperInput.substring(1));
}
helper(arr);
return result;
}
//
$ dart helpermethodrecursion.dart
Unhandled exception:
type 'List' is not a subtype of type 'int'
#0 collectoddValues.helper (file:///G:/DataStructurs/DartAlgorithm/recursion/helpermethodrecursion.dart:15:21)
#1 collectoddValues (file:///G:/DataStructurs/DartAlgorithm/recursion/helpermethodrecursion.dart:20:9)
#2 main (file:///G:/DataStructurs/DartAlgorithm/recursion/helpermethodrecursion.dart:4:9)
#3 _startIsolate. (dart:isolate-patch/isolate_patch.dart:307:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)