Created
February 27, 2023 15:53
-
-
Save olekscode/a207894ded983bed243953eff38453b2 to your computer and use it in GitHub Desktop.
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
prices := #(13 2 13 15 10 8 6.5 14 12 13 8). "prix en euro" | |
"----------------------" | |
sum := 0. | |
prices do: [ :each | | |
sum := sum + each ]. | |
sum. | |
"----------------------" | |
prices select: [ :each | each > 10 ]. "#(13 13 15 14 12 13)" | |
"----------------------" | |
prices reject: [ :each | each > 10 ]. "#(2 10 8 6.5 8)" | |
"----------------------" | |
prices detect: [ :each | each < 10 ]. "2" | |
prices detect: [ :each | each < 10 and: [ each > 5 ] ]. "8" | |
"----------------------" | |
prices collect: [ :each | (each * 658.43) asInteger ]. "#(8559 1316 8559 9876 6584 5267 4279 9218 7901 8559 5267)" | |
"----------------------" | |
prices inject: 0 into: [ :sum :each | sum + each ]. "114.5" | |
prices inject: 1 into: [ :product :each | product * each ]. "4.60631808e10" | |
product := 1. | |
prices do: [ :each | product := product * each ]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment