[ create a new paste ] login | about

fisherro

Name:
Email:
Site/Blog:
Location:
Default language:
Favorite languages:
About:

Saved pastes by fisherro:

C++, pasted on Jun 26:
1
2
3
4
5
#include <iostream>

int main() {

char a_char = 'A';
...
view (11 lines, 3 lines of output)
C++, pasted on Nov 5:
1
2
3
4
5
//See comments to...
//http://programmingpraxis.com/2015/10/30/reverse-string-ignoring-special-characters/#comments
//Requires C++14.
#include <iostream>
#include <string>
...
view (82 lines)
C++, pasted on Aug 23:
1
2
3
4
5
//http://bulldozer00.com/2015/08/20/easier-to-use-and-more-expressive/
//A third C++03 solution

//This is not intended as a criticism of the article.
//It is just an example of an additional solution.
...
view (64 lines, 2 lines of output)
C, pasted on Aug 13:
1
2
3
4
5
#include <stdbool.h>
#include <stdio.h>

//Is the C bool just an int?
//It would appear not.
...
view (11 lines, 1 line of output)
C++, pasted on Aug 13:
1
2
3
4
5
#include <vector>
#include <iostream>
#include <numeric>

//Always make sure the third parameter to std::accumulate is the right type.
...
view (15 lines, 3 lines of output)
C++, pasted on Feb 3:
1
2
3
4
5
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <iostream>
...
view (42 lines, 29 lines of output)
C++, pasted on Feb 3:
1
2
3
4
5
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <iostream>
...
view (19 lines, 2 lines of output)
C, pasted on Jan 27:
1
2
3
4
5
#include <stdio.h>
#include <stdlib.h>

typedef struct Snode_tag
{
...
view (67 lines, 3 lines of output)
Scheme, pasted on Jan 24:
1
2
3
4
5
;http://stackoverflow.com/questions/21327273/scheme-function-to-call-a-procedure-n-times
(require (lib "1.ss" "srfi"))

(define (call-n-times proc n)
      (unfold (lambda (seed) (= n (length seed)))
...
view (10 lines, 5 lines of output)
Scheme, pasted on Sep 2:
1
2
3
4
5
;#lang r5rs
;        11111111112222222222333333333344444444445555555555666666666677777777778
;2345678901234567890123456789012345678901234567890123456789012345678901234567890

; ABOUT
...
view (256 lines, 14 lines of output)
Scheme, pasted on Aug 31:
1
2
3
4
5
;#lang r5rs
;        11111111112222222222333333333344444444445555555555666666666677777777778
;2345678901234567890123456789012345678901234567890123456789012345678901234567890

; ABOUT
...
view (165 lines, 2 lines of output, 1 comment)
Scheme, pasted on Aug 17:
1
2
3
4
; As of 17 August 2013,
; codepad.org says that it uses MzScheme v372,
; and SRFI-71 works.
(require (lib "71.ss" "srfi"))
...
view (9 lines, 2 lines of output)
Scheme, pasted on Aug 9:
1
2
3
4
5
; Functions from standard prelude

(define (string-split sep str)
  (define (f cs xs) (cons (list->string (reverse cs)) xs))
  (let loop ((ss (string->list str)) (cs '()) (xs '()))
...
view (57 lines)
Scheme, pasted on Aug 8:
1
2
3
4
5
; Functions from standard prelude

(define (string-split sep str)
  (define (f cs xs) (cons (list->string (reverse cs)) xs))
  (let loop ((ss (string->list str)) (cs '()) (xs '()))
...
view (61 lines, 3 lines of output)
Scheme, pasted on Aug 8:
1
2
3
4
5
(define input (string->list "rwbrwbrwb"))

(define (dnf1 cs)
  (define (char->num c)
    (case c
...
view (45 lines, 1 line of output)
Scheme, pasted on Jul 15:
1
2
3
4
5
; http://programmingpraxis.com/2013/06/28/a-programming-puzzle/
; Write a function f such that f(f(n)) = -n for all integers n

; Solution one "encodes" the integer into a list.
; This was the only one I came up with before looking at other solutions.
...
view (68 lines, 132 lines of output)
Scheme, pasted on May 10:
1
2
3
4
5
; http://programmingpraxis.com/2013/05/10/mindcipher/

(define (praxis-10-may-2013 y)
 (let ((top (quotient y 100))
       (bottom (modulo y 100))
...
view (17 lines, 1 line of output)
Scheme, pasted on Jan 8:
1
2
3
4
5
;;; http://programmingpraxis.com/2013/01/02/four-points-determine-a-square/

(define candidates
        '(((0 0) (0 1) (1 1) (1 0)) ; the unit square
          ((0 0) (2 1) (3 -1) (1 -2)) ; square not aligned to axis
...
view (40 lines, 7 lines of output)
Scheme, pasted on Jan 8:
1
2
3
4
5
(define (round f n)
 (let ((x (expt 10 n)))
  (/ (truncate (+ (* f x) 0.5)) x)))

(map (lambda (n)
...
view (8 lines, 4 lines of output)
C, pasted on Jan 8:
1
2
3
4
5
#include <stdlib.h>

float raise(float n, int times)
{
    float result = n;
...
view (29 lines, 4 lines of output)