-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reverse
method to NonEmptyTuple
#13752
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d8dfef6
Add reverse method to NonEmptyTuple
danicheg ebd5f2b
Merge branch 'master' into tuple-reverse
danicheg ab1a19f
Update MiMa filters
danicheg ebf8d8c
Merge branch main
danicheg a1d8b66
Address review comments
danicheg 5006b2f
Remove wrong branch in Tuples#xxlReverse
danicheg cb2f91f
Merge branch 'main' into tuple-reverse
danicheg 6aef25a
Move reverse method to Tuple
danicheg ae14dab
Add one more test
danicheg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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,78 @@ | ||
(0) | ||
(0,0) | ||
(1,0,0) | ||
(2,1,0,0) | ||
(3,2,1,0,0) | ||
(4,3,2,1,0,0) | ||
(5,4,3,2,1,0,0) | ||
(6,5,4,3,2,1,0,0) | ||
(7,6,5,4,3,2,1,0,0) | ||
(8,7,6,5,4,3,2,1,0,0) | ||
(9,8,7,6,5,4,3,2,1,0,0) | ||
(10,9,8,7,6,5,4,3,2,1,0,0) | ||
(11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
(24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,0) | ||
() | ||
(1) | ||
(2,1) | ||
(3,2,1) | ||
(4,3,2,1) | ||
(5,4,3,2,1) | ||
(6,5,4,3,2,1) | ||
(7,6,5,4,3,2,1) | ||
(8,7,6,5,4,3,2,1) | ||
(9,8,7,6,5,4,3,2,1) | ||
(10,9,8,7,6,5,4,3,2,1) | ||
(11,10,9,8,7,6,5,4,3,2,1) | ||
(12,11,10,9,8,7,6,5,4,3,2,1) | ||
(13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
() | ||
(1) | ||
(2,1) | ||
(3,2,1) | ||
(4,3,2,1) | ||
(5,4,3,2,1) | ||
(6,5,4,3,2,1) | ||
(7,6,5,4,3,2,1) | ||
(8,7,6,5,4,3,2,1) | ||
(9,8,7,6,5,4,3,2,1) | ||
(10,9,8,7,6,5,4,3,2,1) | ||
(11,10,9,8,7,6,5,4,3,2,1) | ||
(12,11,10,9,8,7,6,5,4,3,2,1) | ||
(13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) | ||
(25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) |
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,73 @@ | ||
import scala.reflect.ClassTag | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
|
||
def testArray[T: ClassTag](n: Int, elem: Int => T): Unit = { | ||
val t: Int *: Tuple = 0 *: Tuple.fromArray(Array.tabulate(n)(elem)) | ||
println(t.reverse) | ||
} | ||
|
||
for (i <- 0 to 25) | ||
testArray(i, j => j) | ||
|
||
val tuple: Tuple3[Int, Boolean, String] = (1, true, "hello") | ||
val reversedTuple: Tuple3[String, Boolean, Int] = tuple.reverse | ||
|
||
assert(reversedTuple == ("hello", true, 1)) | ||
|
||
println(EmptyTuple.reverse) | ||
println(Tuple1(1).reverse) | ||
bishabosha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
println((1, 2).reverse) | ||
println((1, 2, 3).reverse) | ||
println((1, 2, 3, 4).reverse) | ||
println((1, 2, 3, 4, 5).reverse) | ||
println((1, 2, 3, 4, 5, 6).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24).reverse) | ||
println((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25).reverse) | ||
|
||
println(Tuple().reverse) | ||
println((1 *: Tuple()).reverse) | ||
println((1 *: 2 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: Tuple()).reverse) | ||
println((1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: Tuple()).reverse) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.