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 <stdio.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <stdlib.h> | |
static | |
size_t compute_joined_length(const char* separator, | |
const char* first, | |
va_list argp) { | |
size_t seplen = strlen(separator); |
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
/* This is a quite simple set of functions that turns multi-line strings in | |
single line strings with the line breaking characters backslash escaped. | |
The encode_crfl does the following transformation. | |
transform : character -> string | |
transform '\n' = "\\n" | |
transform '\r' = "\\r" | |
transform '\\' = "\\\\" | |
transform c = c |
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
/* As an example, when using a line width of 25, the string: | |
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." | |
Becomes: | |
"Lorem ipsum dolor sit | |
amet, consectetur | |
adipiscing elit, sed do | |
eiusmod tempor incididunt |
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
#!/usr/bin/guile -s | |
!# | |
(use-modules (ice-9 pretty-print)) | |
(define args (command-line)) | |
(if (< (length args) 2) | |
(begin | |
(display "Not enough parameters, need a file name.") | |
(newline)) |
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> | |
int n = 1; | |
struct Printer { | |
Printer() { | |
std::cout << n++ << std::endl; | |
} | |
} array[100]; | |
int main(int argc, char ** argv) { |
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
public class RecursionException { | |
// Print and loop through recursion, throw exception when n reaches zero. | |
public static void loop(int n, int limit) { | |
int x = 1/n; | |
System.out.printf("%1$d\n", (limit - n) + 1); | |
loop(n - 1, limit); | |
} | |
public static void print(int n) { | |
loop(n, n); |
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
public class Lambdas | |
{ | |
public static void main(String args[]) { | |
Printer p = new Printer(); | |
times10(times10(p)).call(); | |
} | |
// The "add" function returns the function that executes the parameters f and g | |
// one after the other. | |
// |
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
// This creates a function that will print n and increment it on every call. | |
function make_printer() { | |
var n = 1; | |
return function() { | |
console.log("%d\n", n++); | |
} | |
} | |
// The "add" function returns the function that executes the parameters f and | |
// g one after the other. |
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
;; This creates a function that will print n and increment it on every call. | |
(define (make-printer) | |
(let ((n 1)) | |
(lambda () | |
(display n) | |
(newline) | |
(set! n (+ n 1))))) | |
;; The "add" function returns the function that executes the parameters f and g | |
;; one after the other. |