Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. -- these are upper limits of ranges, next range depends
  3. -- on some indices from the previous ranges:
  4.  
  5. na = 3 -- necessarily a constant
  6. nb a = 2 -- e.g a constant
  7. nc a b = min a b -- or another function
  8. nd a b c = 2 * b -- e.g. depends on b only
  9.  
  10. u = undefined -- some aruguments are unused,
  11. -- to indicate that we will pass this
  12.  
  13. list1 = [(a, b, c, d) | a <- [1 .. na], b <- [1 .. nb a], c <- [1 .. nc a b], d <- [1 .. nd a b c]]
  14.  
  15. list2 = [(a, b, c, d) | b <- [1 .. nb u], a <- [1 .. na], d <- [1 .. nd u b u], c <- [1 .. nc a b]]
  16.  
  17. main = do
  18. putStrLn "List1:"
  19. putStrLn $ show list1
  20. putStrLn "List2:"
  21. putStrLn $ show list2
  22. putStrLn "How to derive a permutaion list1 <-> list2?"
  23. List1:
  24. [(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)]
  25. List2:
  26. [(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)]
  27. How to derive a permutaion list1 <-> list2?
Add Comment
Please, Sign In to add comment