-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e207ee6
commit 079c1bf
Showing
8 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:y:xs) = y : x : pairswap xs | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Aishwarya G, Dyanesh S | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap x = [x!!1] ++ [x!!0] ++ pairswap (drop 2 x) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Aravind S, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap x = reverse (take 2 x) ++ pairswap (drop 2 x) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Ashwin Anand, Hemsagar with a mistake (:), | ||
-- Jivan Prasadd with mistake of (+), Dharmik, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:xs) = [head xs, x] ++ pairswap (tail xs) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Gokul, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:y:xs) = [y,x] ++ pairswap xs | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Ravi, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:xs) = [head xs] ++ [x] ++ pairswap(drop 1 xs) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Yaswanth, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:y:xs) = [y] ++ [x] ++ pairswap(xs) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Nithin S, Siddharth Krishna, Rakshan K, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pairswap :: [a] -> [a] | ||
pairswap [] = [] | ||
pairswap (x:xs) = [head xs] ++ [x] ++ pairswap(tail xs) | ||
|
||
main :: IO () | ||
main = do | ||
let listInput = [1..6] | ||
stringInput = "ammu" | ||
emptyList = [] | ||
putStrLn $ "Input List:" ++ show listInput | ||
putStrLn $ "Pairwise Swapped List:" ++ show (pairswap listInput) | ||
putStrLn $ "Input String:" ++ stringInput | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap stringInput) | ||
putStrLn $ "Input String:" ++ emptyList | ||
putStrLn $ "Pairwise Swapped String:" ++ (pairswap emptyList) | ||
|
||
-- Solved this way by Ganasekhar, | ||
|