News for hackers. Stuff that matters.
Re:FP techniques that will help you write better JavaScript by xigoi on Friday February 11, 2022 @04:08PM (#30307022)

  const findInterestingItems = (arr, isInteresting, num, i=0) =>
    num == 0 || i >= arr.length
    ? []
    : isInteresting(arr[i])
      ? [arr[i], ...findInterestingItems(arr, isInteresting, num-1, i+1)]
      : findInterestingItems(arr, isInteresting, num, i+1)
Re:FP techniques that will help you write better JavaScript by bryanrasmussen on Friday February 11, 2022 @04:45PM (#30307390)
I don't see where you used map? You made a recursive function? the argument was clearly stated - person says all most programmers need is map and reduce on arrays. I agree that by recursing you also have found another way not to use break but you have evidently had to NOT use map and reduce to do it?

on edit: also how will that recursion perform on the large array we've supposed as being used if it turns out that we don't get our interesting items in early parts of array?

Re:FP techniques that will help you write better JavaScript by bryanrasmussen on Friday February 11, 2022 @06:00PM (#30308049)
ok someone showed a way you can achieve break like functionality with map https://news.ycombinator.com/item?id=30306256 by mutating the array parameter of the map.