Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- these are upper limits of ranges, next range depends
- -- on some indices from the previous ranges:
- na = 3 -- necessarily a constant
- nb a = 2 -- e.g a constant
- nc a b = min a b -- or another function
- nd a b c = 2 * b -- e.g. depends on b only
- u = undefined -- some aruguments are unused,
- -- to indicate that we will pass this
- list1 = [(a, b, c, d) | a <- [1 .. na], b <- [1 .. nb a], c <- [1 .. nc a b], d <- [1 .. nd a b c]]
- list2 = [(a, b, c, d) | b <- [1 .. nb u], a <- [1 .. na], d <- [1 .. nd u b u], c <- [1 .. nc a b]]
- main = do
- putStrLn "List1:"
- putStrLn $ show list1
- putStrLn "List2:"
- putStrLn $ show list2
- putStrLn "How to derive a permutaion list1 <-> list2?"
- List1:
- [(1,1,1,1),(1,1,1,2),(1,2,1,1),(1,2,1,2),(1,2,1,3),(1,2,1,4),(2,1,1,1),(2,1,1,2),(2,2,1,1),(2,2,1,2),(2,2,1,3),(2,2,1,4),(2,2,2,1),(2,2,2,2),(2,2,2,3),(2,2,2,4),(3,1,1,1),(3,1,1,2),(3,2,1,1),(3,2,1,2),(3,2,1,3),(3,2,1,4),(3,2,2,1),(3,2,2,2),(3,2,2,3),(3,2,2,4)]
- List2:
- [(1,1,1,1),(1,1,1,2),(2,1,1,1),(2,1,1,2),(3,1,1,1),(3,1,1,2),(1,2,1,1),(1,2,1,2),(1,2,1,3),(1,2,1,4),(2,2,1,1),(2,2,2,1),(2,2,1,2),(2,2,2,2),(2,2,1,3),(2,2,2,3),(2,2,1,4),(2,2,2,4),(3,2,1,1),(3,2,2,1),(3,2,1,2),(3,2,2,2),(3,2,1,3),(3,2,2,3),(3,2,1,4),(3,2,2,4)]
- How to derive a permutaion list1 <-> list2?
Add Comment
Please, Sign In to add comment