S

@supriyo_biswas

Recursive filter

Python
6 years ago
def filter_rec(fn, elems): results = [] for elem in elems: if isinstance(elem, list): result = filter_rec(fn, elem) if result: results.append(result) elif fn is None: if elem:

Password hash importer

PHP
6 years ago
#!/usr/bin/php <?php set_error_handler(function ($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }); function println($str) { echo $str, "\n"; }

Password importer

PHP
6 years ago
#!/usr/bin/php <?php set_error_handler(function ($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }); function println($str) { echo $str, "\n"; }

Splitting integers

PHP
6 years ago
<?php function cut(int $total) { $result = []; while ($total > 0) { $new = random_int(1, $total); $result []= $new; $total -= $new; }

Pointers: Arithmetic on double pointers

C
6 years ago
#include <stdio.h> int main() { // a two dimensional array int a[2][4] = {{4, 2, 7, 8}, {1, 3, 5, 9}}; // two loop variables int i, j; for (i = 0; i < 2; i++) {

Pointers: Creating and updating a pointer-to-pointer

C
6 years ago
#include <stdio.h> int main() { // two int variables and pointers pointing to them int x = 10, *p = &x; int y = 20, *q = &y; // create a pointer-to-pointer, pointing to p int **r = &p;

Pointers: constant pointers

C
6 years ago
#include <stdio.h> int main() { // declare two variables. int x = 10, y = 20; // declare a constant pointer to the variable x int *const p = &x; // print the value of a through x.

Pointers: constant pointers

C
6 years ago
#include <stdio.h> int main() { // declare two const-qualified variables. const int x = 10, y = 20; // declare a pointer to the const-qualified variable x const int *p = &x; // print the value of a through x.

Pointers: Using the pointer constant syntax

C
6 years ago
#include <stdio.h> void print_array(int q[], int size) { // q is a pointer constant. int i; for (i = 0; i < size; i++) { printf("%d ", q[i]); }

Pointers: Using the pointer constant syntax

C
6 years ago
#include <stdio.h> void add_one(int q[]) { // because 'q' is just a special kind of pointer // called a constant pointer, this statement works // as you would expect. *q = *q + 1; }

Pointers: passing arrays to functions

C
6 years ago
#include <stdio.h> void add_one(int *b, int size) { int i; // add one to each element of b for (i = 0; i < size; i++) { b[i]++; } }

Pointers: Simulating call by reference

C
6 years ago
#include <stdio.h> void add_one(int *q) { printf("initial value of *q from add_one() = %d\n", *q); *q = *q + 1; printf("final value of *q from add_one() = %d\n", *q); } int main() { int x = 10, *p = &x;

Pointers: Function calls and copying of parameters

C
6 years ago
#include <stdio.h> void add_one(int v) { printf("initial value of v from add_one() = %d\n", v); v = v + 1; printf("final value of v from add_one() = %d\n", v); } int main() { int x = 10;

Pointers: relational operators and pointers

C
6 years ago
#include <stdio.h> int main() { // declare two integers. int a = 10, b = 20; // declare two pointers pointing to 'a' and 'b'. int *p = &a, *q = &b; // working with relational operators and pointers.

Pointers: subtracting two pointers

C
6 years ago
#include <stdio.h> int main() { // two integers. int a = 10, b = 20; // two pointers, pointing to 'a' and 'b' int *p = &a, *q = &b; // print the difference between the pointers

Pointers: array traversal with pointer arithmetic

C
6 years ago
#include <stdio.h> int main() { // an array. int a[] = {10, 20, 30, 40}; // a pointer p, with the same value as a. int *p = a; // a loop variable.

Pointers: commutative property of pointer-integer addition

C
6 years ago
#include <stdio.h> int main() { // An array of four elements. // Remember that "a" is a "constant pointer". int a[] = {10, 20, 30, 40}; // A loop variable. int i;

Pointers: array subscripts and pointer arithmetic

C
6 years ago
#include <stdio.h> int main() { // An array of four elements. // Remember that "a" is a "constant pointer". int a[] = {10, 20, 30, 40}; // A loop variable. int i;

Pointers: adding and subtracting pointers with integers

C
6 years ago
#include <stdio.h> int main() { int a = 10; // get the address of a and store it in p. int *p = &a; // add 10 to p and store it in q. int *q = p + 10;

Pointers: pointers and arrays.

C
6 years ago
#include <stdio.h> int main() { // declaring an array and a loop variable. int a[] = {10, 20, 30, 40}, i; // because 'a' behaves like an array and // stores an address, copy the address into // a pointer p. int *p = a;