[racket] HTDP 17.1.2; applying methodology to imperative languages

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Mar 30 22:23:33 EDT 2011


On Mar 30, 2011, at 10:10 PM, Jay wrote:

> Hi,
> 
> I have two unrelated questions, and I hope no one will mind my bundling them together:
> 
> 1) I'm stumped by the "cross" problem (17.1.2). Although I did manage to dig up someone else's solution, and do understand it, I would never have recognized it from the problem description as an instance of two-lists-with-one-treated-atomically. Aside from its location in the text, is there a way of looking at this problem that helps identify the technique? Even knowing the answer, I'm not sure what should have been on my auxiliary function "wish list."


Would you find this more comprehensible? 

#lang racket 

(require rackunit)

;; cross : [Setof X] [Setof Y] -> [Setof [List X Y]]
(define (cross s t)
  (for*/set ((1s s) (1t t)) (list 1s 1t)))

(check-equal? (cross (set 1 2 3) (set 'a 'b)) (set '(1 a) '(1 b) '(2 a) '(2 b) '(3 a) '(3 b)))


> 2) Is there a post or other resource that describes how HTDP methodology can be applied to programming in other languages? I'm interested in C++, but I imagine discussions of any imperative language would be helpful.

Of course. See HtDC. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110330/47788da0/attachment.html>

Posted on the users mailing list.