I'm using the beginning language with list abbreviations for DrRacket and want to make a powerset recursively but cannot figure out how to do it. I currently have this much
(define
(powerset aL)
(cond
[(empty? aL) (list)]
any help would be good.
Here's yet another implementation, after a couple of tests it appears to be faster than Chris' answer for larger lists. It was tested using standard Racket:
Here's my implementation of power set (though I only tested it using standard Racket language, not Beginning Student):
(Thanks to samth for reminding me that flatmap is called
append-map
in Racket!)In Racket,
To test: