Created
October 16, 2016 05:42
-
-
Save 97jaz/7676e91efee02584f850f24e51b87d63 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#lang racket/base | |
(require racket/match) | |
(define (each+others/non-index cs [prev '()] [res '()]) | |
(match cs | |
['() res] | |
[(cons c cs) (each+others/non-index cs | |
(cons c prev) | |
(cons (cons c (append prev cs)) res))])) | |
;; example: | |
;; > (each+others/non-index (string->list "hello")) | |
;; '((#\o #\l #\l #\e #\h) (#\l #\l #\e #\h #\o) (#\l #\e #\h #\l #\o) (#\e #\h #\l #\l #\o) (#\h #\e #\l #\l #\o)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment