Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell: Sets

Name: Anonymous 2015-08-17 18:24

Given a finite Set type (not Data.Set), find a map Set -> Int that is bijective! (Let's try injective first, how would you do that?)

The definition of Set I have in mind is this:
data Set = Empty | Set [Set]
But if you want to use some other equivalent definition go ahead.

Name: Anonymous 2015-08-21 19:10

Fucking haskell, I have to fucking format my system to install an update. This is the Set -> Int injection I had in mind.

concatInteger :: [Integer] -> Integer
concatInteger = read . concatMap show

setLen Empty = 0
setLen (Set s) = length s

set2List Empty = []
set2List (Set s) = length s : sort $ concatMap set2List s

set2Int = concatInteger . set2List

Name: Anonymous 2015-08-21 19:11

>>17
Disregard setLen. It's not needed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List