Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pp:l04 [2021/03/27 11:58]
aghiculescu
pp:l04 [2023/03/22 18:54] (current)
mihai.udubasa old revision restored (2021/03/28 20:51)
Line 41: Line 41:
 2.1. Write a function that computes the scalar product with an integer: 2.1. Write a function that computes the scalar product with an integer:
  
-$math[ \displaystyle 2 * \left(\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{array}\right) = \left(\begin{array}{ccc} ​& 4 & 6 \\ 8 & 10 & 12 \\ 14 & 16 & 18 \\ \end{array}\right)] ​+$math[ \displaystyle 2 * \left(\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{array}\right) = \left(\begin{array}{ccc} ​& 4 & 6 \\ 8 & 10 & 12 \\ 14 & 16 & 18 \\ \end{array}\right)] ​
  
 <code haskell> <code haskell>
Line 75: Line 75:
 2.5. Write a function which computes the transposition of a matrix: 2.5. Write a function which computes the transposition of a matrix:
  
-$math[ ​transpose ​\left(\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{array}\right) = \left(\begin{array}{ccc} 1 & 4 & \\ 2 & 5 & 8 \\ 3 & 6 & 9 \\ \end{array}\right) ]+$math[ ​tr \left(\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{array}\right) = \left(\begin{array}{ccc} 1 & 4 & \\ 2 & 5 & 8 \\ 3 & 6 & 9 \\ \end{array}\right) ]
  
 <code haskell> <code haskell>
-transpose ​:: [[a]] -> [[a]] +tr :: [[a]] -> [[a]] 
-transpose ​([]:_) = +tr ([]:_) = 
-transpose ​m =+tr m =
 </​code>​ </​code>​
  
Line 164: Line 164:
 $math[ maskDiscard\left(\begin{array}{ccc} ​ &  & * \\  &  & * \\  &  & * \\ \end{array}\right) \left(\begin{array}{ccc} * &  & * \\ * &  &  \\ * &  & * \\ \end{array}\right) = \left(\begin{array}{ccc} ​ &  &  \\  &  & * \\  &  &  \\ \end{array}\right) ] $math[ maskDiscard\left(\begin{array}{ccc} ​ &  & * \\  &  & * \\  &  & * \\ \end{array}\right) \left(\begin{array}{ccc} * &  & * \\ * &  &  \\ * &  & * \\ \end{array}\right) = \left(\begin{array}{ccc} ​ &  &  \\  &  & * \\  &  &  \\ \end{array}\right) ]
  
-3.9. Implement the ''​union''​ of two images.+3.9. Implement the ''​union'''​ of two images.
 <code haskell> <code haskell>
-union :: Image -> Image -> Image +union' ​:: Image -> Image -> Image 
-union = +union' ​
 </​code>​ </​code>​
 $math[ union \left(\begin{array}{ccc} ​ &  & * \\  &  & * \\  &  & * \\ \end{array}\right) \left(\begin{array}{ccc} * &  & * \\ * &  &  \\ * &  & * \\ \end{array}\right) = \left(\begin{array}{ccc} * &  & * \\ * &  & * \\ * &  & * \\ \end{array}\right) ] $math[ union \left(\begin{array}{ccc} ​ &  & * \\  &  & * \\  &  & * \\ \end{array}\right) \left(\begin{array}{ccc} * &  & * \\ * &  &  \\ * &  & * \\ \end{array}\right) = \left(\begin{array}{ccc} * &  & * \\ * &  & * \\ * &  & * \\ \end{array}\right) ]
Line 177: Line 177:
 Test it with the following sequence Test it with the following sequence
 <code haskell> <code haskell>
-seq1 = transformation_sequence ​[invert, union mask, rotate90right]+seq1 = transformationSequence ​[invert, union' ​mask, rotate90r]
 </​code>​ </​code>​