Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
pp:l04 [2021/03/27 11:54] 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} 1 & 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} 2 & 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 & 6 \\ 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 & 7 \\ 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> | ||
| Line 196: | Line 196: | ||
| <code haskell> | <code haskell> | ||
| logo = [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19] | logo = [l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19] | ||
| - | where l1=" ***** ** ***** ** " | + | where l1 =" ***** ** ***** ** " |
| - | l2=" ****** **** ****** **** " | + | l2 =" ****** **** ****** **** " |
| - | l3=" ** * * *** ** * * *** " | + | l3 =" ** * * *** ** * * *** " |
| - | l4=" * * * *** * * * *** " | + | l4 =" * * * *** * * * *** " |
| - | l5=" * * ** * * ** " | + | l5 =" * * ** * * ** " |
| - | l6=" ** ** ** ** ** ** " | + | l6 =" ** ** ** ** ** ** " |
| - | l7=" ** ** ** ** ** ** " | + | l7 =" ** ** ** ** ** ** " |
| - | l8=" **** ** * **** ** * " | + | l8 =" **** ** * **** ** * " |
| - | l9=" * *** ** * * *** ** * " | + | l9 =" * *** ** * * *** ** * " |
| l10=" ** ******* ** ******* " | l10=" ** ******* ** ******* " | ||
| l11=" ** ****** ** ****** " | l11=" ** ****** ** ****** " | ||