Skip to content

Commit ec7125d

Browse files
authored
Adding a link to Solutions from for-loops.md and extending the answer to the bonus questions. (#213)
* Update for-loops.md * Update solutions-morning.md
1 parent 4760295 commit ec7125d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/exercises/day-1/for-loops.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ slice-of-slices. Why or why not?
7373

7474
See the [`ndarray` crate](https://docs.rs/ndarray/) for a production quality
7575
implementation.
76+
77+
<details>
78+
79+
The solution and the answer to the bonus section are available in the
80+
[Solution](solutions-morning.md#arrays-and-for-loops) section.
81+
82+
</details>

src/exercises/day-1/solutions-morning.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111

1212
It honestly doesn't work so well. It might seem that we could use a slice-of-slices (`&[&[i32]]`) as the input type to transpose and thus make our function handle any size of matrix. However, this quickly breaks down: the return type cannot be `&[&[i32]]` since it needs to own the data you return.
1313

14-
You can attempt to use something like `Vec<Vec<i32>>`, but this doesn't work very well either: it's hard to convert from `Vec<Vec<i32>>` to `&[&[i32]]` so now you cannot easily use `pretty_print` either.
14+
You can attempt to use something like `Vec<Vec<i32>>`, but this doesn't work very well either: it's hard to convert from `Vec<Vec<i32>>` to `&[&[i32]]` so now you cannot easily use `pretty_print` either.
15+
16+
In addition, the type itself would not enforce that the child slices are of the same length, so such variable could contain an invalid matrix.

0 commit comments

Comments
 (0)