1
Name:
Anonymous
2012-02-29 8:48
I really don't understand what the purpose of closures is. It seems to me that everything that can be written using closures, is just as easily written without. For example:
void main()
{
int[] haystack = [345,15,457,9,56,123,456];
int needle = 123;
bool needleTest(int n)
{
return n == needle;
}
printf(find(haystack, &needleTest));
}
Wouldn't this be better written as:
void main()
{
int[] haystack = [345,15,457,9,56,123,456];
int needle = 123;
foreach(int i : haystack)
{
if (i == needle)
{
printf(i);
}
}
}
Or at least defining the function outside of main() and referencing it inside? I just don't understand the benefit of closures.
24
Name:
Anonymous
2012-03-02 12:08
>>23
This will spam threads with three digit post counts, you talentless hack!
25
Name:
Anonymous
2012-03-02 12:16
>>24
getPostNum only returns values in the range of 1-99.
26
Name:
Anonymous
2012-03-02 12:17
>>23
UuUUUu U UuuUUUu!!!??! uUu UuUu UUUUu u Uuuu u uuuu UUUUu u U??!??!! U uUu!??!?!! uuuu uu U!?!??!! U UUuu uuUu uUUUu Uu uuUu uUUUu UUUUu!!???!! uUUu U?!!??!! uuuu uu U!?!??!! uUUu uuUu U uUUUu UUUu u??!??!! UUuUuu UUuuuu UUUuUUu uUuuuu Uuuuuu UuuUuu uUUuuu uUUuuu UUuUuu UUUu UUuuuu UUUuUUu uUuuuu Uuuuuu UuuUuu uUUuUUu uuUuUUu UuUuuu UUUUUUu UuuuUUu Uuuuuu UUuUuu UUuuuu UUUuUUu uUuuuu Uuuuuu UuuUuu U U UUuUuu UUUu UUuuuu UUUuUUu uUuuuu Uuuuuu UuuUuu uuu!!!??! U UuUuUu!??!??! U uuUu!??!?!! U!????!! uUu uUUUu U UUuu UUu UuuUu Uuuu uUUUu UuUu!????!! uuu UUu Uuu U!?!??!! U uuuu uuuUu UuUuu uUUUUu?!??!?! uuUUu uuu U uuUUu!????!! U uuUu uuUu Uuuu UuuUu UuUUu!????!! uUUuuu uUuUUUu UUUuuu UUUuuu U uuuUUUu uuUuuu UUuuuu uUUUUUu Uuuuuu UUuuuu uUUUUUu UuUuuu!?!!?! UUUUu uu U uu UuUu uUUUu?!???!! uUu U!!!!?!! Uuuu u U u Uu uUu UuUu u??!??!! uuuu uu U!?!??!! uuUUuu UuuUuu uUuuUu UuuUUu UUuUuu U!!!!!! tomot
27
Name:
Anonymous
2012-03-02 12:18
>>26
I'm
>>23- san, and I thought that was hilarious
!
29
Name:
Anonymous
2012-03-02 12:29
>>28
I think it's because humans have generally used base 10 as a counting system (though there are some notable exceptions), due to the fact that they have 10 fingers. It makes sense, then, that any programming language designed by humans will use base ten. There is, however, notational support in D for base 2, base 8, and base 16 numbers.
30
Name:
Anonymous
2012-03-02 12:30
>>27
UuUUUu uUuuUUu U UUuuUUu!!!??! U u Uuu?!!!?!! uuuu uUUUu UUuu UUuu uuUu uuuu u U??!??!! uUu U!!!!?!! U uu?!???!! U!????!! Uuuuuu uuUUUUu uuuuuu uUUuuu U??!!?! uuuuuu uUUUUUu UUuUUUu uUUUUUu UUUUUUu U?!!!?! UuUUUu uUuuUUu U UUuuUUu!!!??! U uUuu!????!! Uu uuUu U UUuu u Uu u!!???!! uuuuuu uuuUuu uUuUUUu uUuUUUu uuUUuu uUUuuu uuuUuu U?!!!?! U!??!??! UUuu uuUu uuuu UUUUu u U??!??!! uuuu uu U!?!??!! UUUUu UUuu UuUUu uuuu U Uu!!???!! U uUUu UUuu?!!??!! U uUuu!????!! UuuUuu uuuuuu UUuUuu UUUUUUu uUuUuu UuuUuu uuUUUUu U uUuUuu UuuUuu UUuUuu UUUUUUu uUuUuu UuuUuu uuUUUUu!!!!?! UUuu U u uuUu???!?!! uUUUUUu uuUUUUu UuuUUUu UuUUUUu uUuuuu UuUUUUu uuUuuu U??!!?! uu U?!!??!! UuUu U Uuu!!!!?!! uUuUuu uuUUuu UUuUUUu uuuUuu U?!!!?! U uUUUUu UuuUUu?!!!??! uuUUu uuu U uuUUu!????!! UuUu U Uuu!!!!?!! Uu U uUuu!????!! U uUUUu U uUUu!?!??!! uUUUu UUu U uu!????!! UuuUUUu UuUuuu uuUuuu uUuUUUu U?!!!?! tomot
31
Name:
Anonymous
2012-03-02 12:32
>>29
So does D store numeric types in 4-bit-encoded base 10 like COBOL? (I forget the name of this practice)
32
Name:
Anonymous
2012-03-02 12:36
>>31
No, it stores them as 32 bit base 2 numeric types; and the term you're looking for is Binary Coded Decimal.
33
Name:
Anonymous
2012-03-02 12:36
dubs n = (n `mod` 100) `mod` 11 == 0
35
Name:
Anonymous
2012-03-03 1:50
>>30
I thought it was kind of funny too. Free-thinking rule redefining rebels? LOL
36
Name:
Anonymous
2012-03-03 6:08
>>31
It's called BCD. (Binary-Coded Decimals, or so)