카타 8급 Enumerable Magic #1 - True for All?

1 C[ | ]

#include <stdbool.h>
#include <stddef.h>
typedef bool (*Predicate)(int);
bool all(int* arr, size_t size, Predicate fun) {
  for(int i=0; i<size; i++) {
    if( !fun(arr[i]) ) return false;
  }
  return true;
}

2 JavaScript[ | ]

function all( arr, fun ) {
  return arr.every(fun);
}
function all( arr, fun ) {
  for(x of arr) {
    if( !fun(x) ) return false;
  }
  return true;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}