Skip to main content

All Questions

3 votes
2 answers
5k views

Using 'reduce' vs 'for' loop for returning boolean [closed]

I was wondering what people think about using a reduce function vs loop for returning true if a condition exists. Example: var a = [1, 5, 7, 4, 2, 5, 3]; var greaterThan5 = a.reduce(function(prev, ...
Tony Brix's user avatar
  • 205
9 votes
1 answer
3k views

Functional programming for loop side effect

I am trying to get my head around as to why having a local variable or a for loop inside a function is not considered to be pure functional programming. Given this function: int as_int(char *str) { ...
tomatoRadar's user avatar
0 votes
1 answer
233 views

LOOP program only need inc and zero

I have 4 different commands in LOOP programming language: y=Zero() y=Val(x)=copy x and put it in register y y=Inc(x)=x+1 y=Dec(x)=x-1 Finally I also have loop n times { ... ...
Voyage's user avatar
  • 133