PasteRack.org
Paste # 97469
2019-05-01 00:56:18

Fork as a new paste.

Paste viewed 372 times.


Embed:

need help with basic iter functions

#lang racket

;; Basically, I want to make 2 scripts, but solving any of these would be very helpful.

;; Script 1 -- linewise combinations

(print-line-for-each-line-of-combinations "one bit " ("string1" "string2") " last bit")
(print-line-for-each-line-of-combinations "one bit " ("string1" "string2") " middle-bit " ("stringA" "stringB") " last bit")

;; Output 1

"one bit string1 middle-bit stringA last bit"
"one bit string2 middle-bit stringB last bit"

;; Script 2 -- all combinations

(print-line-for-each-combination "one bit " ("string 1" "string 2") " last bit")
(print-line-for-each-combination "one bit " ("string1" "string2") " middle-bit " ("stringA" "stringB") " last bit")

;; Output 2

"one bit string1 middle-bit stringA last bit"
"one bit string1 middle-bit stringB last bit"
"one bit string2 middle-bit stringA last bit"
"one bit string2 middle-bit stringB last bit"