fisherro
|
codepad
|
|
fisherro
|
Saved pastes by fisherro:
//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) |
//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) |
#include <stdbool.h>
#include <stdio.h>
//Is the C bool just an int?
//It would appear not.
|
view (11 lines, 1 line of output) |
#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) |
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <iostream>
|
view (42 lines, 29 lines of output) |
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <iostream>
|
view (19 lines, 2 lines of output) |
;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) |
;#lang r5rs
; 11111111112222222222333333333344444444445555555555666666666677777777778
;2345678901234567890123456789012345678901234567890123456789012345678901234567890
; ABOUT
|
view (256 lines, 14 lines of output) |
;#lang r5rs
; 11111111112222222222333333333344444444445555555555666666666677777777778
;2345678901234567890123456789012345678901234567890123456789012345678901234567890
; ABOUT
|
view (165 lines, 2 lines of output, 1 comment) |
; 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) |
; 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) |
; 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) |
(define input (string->list "rwbrwbrwb"))
(define (dnf1 cs)
(define (char->num c)
(case c
|
view (45 lines, 1 line of output) |
; 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) |
; 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) |
;;; 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) |
(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) |