Joined October 2017
·

Andreas Hefti

·

Posted to Scala week 3 over 1 year ago

I think there is a bug in

MaxRet(left.mostRetweeted,MaxRet(left.mostRetweeted,elem))

shouldn't it be?:

MaxRet(left.mostRetweeted,MaxRet(right.mostRetweeted,elem))

and instead of

if (left.isEmpty && right.isEmpty) elem
else if (right.isEmpty) MaxRet(left.mostRetweeted,elem)
else if (left.isEmpty) MaxRet(right.mostRetweeted,elem)
MaxRet(left.mostRetweeted,MaxRet(right.mostRetweeted,elem))

you can also write

MaxRet(
    if (left.isEmpty) elem else left.mostRetweeted,
    MaxRet(if (right.isEmpty) elem else right.mostRetweeted, elem)
)
Achievements
1 Karma
0 Total ProTip Views