8 kyu

Enumerable Magic #1 - True for All?

6,679 of 12,779bellmyer

Description:

Task

Create a method all which takes two params:

  • a sequence
  • a function (function pointer in C)

and returns true if the function in the params returns true for every element in the sequence. Otherwise, it should return false. If the sequence is empty, it should return true, since technically nothing failed the test.

Example

all((1, 2, 3, 4, 5), greater_than_9) -> false
all((1, 2, 3, 4, 5), less_than_9)    -> True

Help

Here's a (Ruby) resource if you get stuck:

http://www.rubycuts.com/enum-all

Arrays
Fundamentals

Stats:

CreatedNov 5, 2014
PublishedNov 5, 2014
Warriors Trained20933
Total Skips1071
Total Code Submissions41249
Total Times Completed12779
Ruby Completions1265
JavaScript Completions6679
CoffeeScript Completions36
C# Completions881
C Completions690
Prolog Completions52
Java Completions903
Python Completions2802
Total Stars178
% of votes with a positive feedback rating91% of 1838
Total "Very Satisfied" Votes1555
Total "Somewhat Satisfied" Votes217
Total "Not Satisfied" Votes66
Ad
Contributors
  • bellmyer Avatar
  • jhoffner Avatar
  • JoshSchreuder Avatar
  • phatcabbage Avatar
  • ZozoFouchtra Avatar
  • werner33 Avatar
  • asmgf Avatar
  • ParanoidUser Avatar
  • user5036852 Avatar
  • B1ts Avatar
  • Blind4Basics Avatar
  • FArekkusu Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • albertogcmr Avatar
  • hakr14 Avatar
  • akar-0 Avatar
  • KayleighWasTaken Avatar
Ad