3 ms·
Are you familiar with Rust, Haskell, C# or JavaScript? All of these allow creating new extension methods of existing types, albeit by three different methods.
by AaronFriel 9y ago
Are you familiar with Rust, Haskell, C# or JavaScript?
All of these allow creating new extension methods of existing types, albeit by three different methods.
I'm assuming that your "2001.to_year - 1" is "the date time for 2001 minus 1 day"
rust (traits)
(pow::<BigInt>(2u8, 1000).digits().sum()
(2..10_000).amicable_numbers().sum()
1901.to_year().upto(2001.to_year() - 1.to_day()).days().iter().filter(|d| d.mday + d.wday == 1).count()
Haskell (type classes)
sum . digits $ 2 ^ 1000
sum $ amicable_numbers [2..10000]
count $ filter (\d -> mday d + wday d == 1) [year 1901 .. year 2000 - day 1]
C# (extension methods)
BigInteger.Pow(2, 1000).digits().sum()
Enumerable.range(2,10000).amicable_numbers().sum()
1901.ToYear().UpTo(2001.ToYear() - 1.ToDay()).Days().Where(d => d.mday + d.wday == 1).Count()
JavaScript (changing prototypes)
bigInt(2).pow(1000).digits().sum()
_.range(2, 10000).amicable_numbers().sum()
1901.to_year().upto(2001.to_year().minus(1)).days().filter(d => d.mday + d.wday === 1).length()
- stouset 9y agoYes, I am familiar with all of them. :) Rust most of all, and that's another language I'm extremely happy with. The others to lesser extents, and Javascript is the only one of them where I'd say I dislike the language.