This language bar is your friend. Select your favorite languages!

Idiom #20 Return two values

Implement a function search which looks for item x in a 2D matrix m.
Return indices i, j of the matching cell.
Think of the most idiomatic way in the language to return the two values at the same time.

#Edit dateEdit SummaryEditor
👁 Δ 61 2019-09-27, 08:58 [PHP] Format code snippet to PSR-12 ancarda
👁 Δ 60 2019-09-26, 21:34 [Clojure] Used the threading macro where appropriate. jasonrobot
👁 Δ 59 2019-09-26, 20:20 New Fortran implementation by user [tkoenig] tkoenig
👁 Δ 58 2019-09-26, 19:40 New Cpp implementation by user [jdashg] jdashg
👁 Δ 57 2019-09-26, 17:04 [Caml] typo in comments andrepd
👁 Δ 56 2019-09-26, 17:04 [Caml] mistake andrepd
👁 Δ 55 2019-09-26, 17:02 New Caml implementation by user [andrepd] andrepd
👁 Δ 54 2019-09-26, 15:56 [Cpp] fixed small grammar mistake archi
👁 Δ 53 2019-09-26, 15:56 New Cpp implementation by user [archi] archi
👁 Δ 52 2019-09-26, 15:45 New Lisp implementation by user [foobar] foobar
👁 Δ 51 2019-09-26, 15:33 [Rust] Add missing return. Sh4rK
👁 Δ 50 2019-09-26, 15:22 [Csharp] Removed optional brackets to make comparison with other languages easier. reifnir
👁 Δ 49 2019-09-26, 15:21 [Csharp] Updated to modern C# idiom. Also, previous example was incorrect (didn't even compile, as MDAs don't have a Cou... reifnir
👁 Δ 48 2019-06-17, 22:37 [Ruby] conform to given variable name m steenslag
👁 Δ 47 2019-02-02, 03:06 New Scala implementation by user [Debaran] Debaran
👁 Δ 46 2017-12-28, 22:35 [C] Typo in comments programming-idioms.org
👁 Δ 45 2017-09-01, 18:32 [Clojure] Variable name is x programming-idioms.org
👁 Δ 44 2017-09-01, 15:46 New Clojure implementation by user [Jerry] Jerry
👁 Δ 43 2017-04-03, 18:36 [Rust] Specifying return isn't required in rust, therefore doesn't need to be specified. Doctors
👁 Δ 42 2016-11-04, 11:52 [Csharp] Variable names programming-idioms.org
👁 Δ 41 2016-10-28, 07:52 [Csharp] Function name SearchMatrix -> Search programming-idioms.org
👁 Δ 40 2016-10-28, 07:50 [Haskell] Typo searcb -> search programming-idioms.org
👁 Δ 39 2016-04-07, 07:24 New Lua implementation by user [Nepta]
👁 Δ 38 2016-04-05, 04:13 New Erlang implementation by user [elbrujohalcon]
👁 Δ 37 2016-03-21, 23:40 Linked to idiom #126 [Multiple return values]
👁 Δ 36 2016-02-24, 15:45 New PHP implementation by user [agilla1]
👁 Δ 35 2016-02-20, 23:33 [Go] "for i" more idiomatic than "for i, _"
👁 Δ 34 2016-02-20, 18:48 New Csharp implementation by user [Marti_2203]
👁 Δ 33 2016-02-20, 18:47 New Csharp implementation by user [Marti_2203]
👁 Δ 32 2016-02-20, 18:47 New Csharp implementation by user [Marti_2203]
👁 Δ 31 2016-02-20, 18:47 New Csharp implementation by user [Marti_2203]
👁 Δ 30 2016-02-20, 18:27 New Csharp implementation by user [Marti_2203]
👁 Δ 29 2016-02-18, 17:19 Restored version 27
👁 Δ 28 2016-02-18, 16:57
👁 Δ 27 2016-02-17, 20:37 New Ada implementation by user [Smaehtin]
👁 Δ 26 2015-11-30, 12:37
👁 Δ 25 2015-10-29, 14:05
👁 Δ 24 2015-09-04, 19:57
👁 Δ 23 2015-09-04, 19:41
👁 Δ 22 2015-09-04, 19:40
👁 Δ 21 2015-09-04, 19:39
👁 Δ 20 2015-09-04, 19:23
👁 Δ 19 2015-09-04, 19:23
👁 Δ 18 2015-09-04, 19:16
👁 Δ 17 2015-09-04, 19:10
👁 Δ 16 2015-09-04, 18:59
👁 Δ 15 2015-09-04, 18:58
👁 Δ 14 2015-09-03, 17:30
👁 Δ 13 2015-08-22, 00:40
👁 Δ 12 2015-08-22, 00:39
👁 Δ 11 2015-08-21, 16:18
👁 Δ 10 2015-08-20, 18:25
👁 Δ 9 2015-08-20, 15:51
👁 Δ 8 2015-08-20, 10:48
👁 Δ 7 2015-08-19, 17:37
👁 Δ 6 2015-07-31, 19:42
👁 Δ 5 2015-07-31, 19:41
👁 Δ 4 2015-07-31, 19:41
👁 Δ 3 2015-05-06, 21:04
👁 Δ 2 2015-03-11, 12:28
1 2015-03-11, 12:19