This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <numeric> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> array = {1, 2, 3, 4, 5}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reduce (lambda (x y) (+ x (* y 2))) '(1 2 3 4 5) :initial-value 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foldl (\x y -> x + y*2) 0 [1, 2, 3, 4, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lists:foldl(fun(Y, X) -> X + Y*2 end, 0, [1,2,3,4,5]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use List::Util qw(reduce); | |
my $r = reduce { $a + $b * 2 } 0, 1..5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reduce(lambda x, y: x + y*2, [1,2,3,4,5], 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#(1 2 3 4 5) inject: 0 into: [ :x :y | x + (y*2) ]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accumulate(array.begin(), | |
array.end(), 0, | |
[](const int& x, const int& y) -> int { return x + y*2; }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int foo() | |
{ | |
matrix a = NULL, b = NULL, c = NULL; | |
matrix_ctx ctx = NULL; | |
matrix_start(ctx); | |
a = matrix_new(ctx, 1000, 1000); | |
b = matrix_new(ctx, 1000, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ knowledge starts from here | |
%% the database knows these people | |
person('Mary Brod'). | |
person('Carl Stuckart'). | |
person('Rudolf Fisher'). | |
person('Amanda Least'). | |
person('Minority Report'). | |
%% when they are born | |
born('Mary Brod', date(1988, 3, 11)). |
OlderNewer