Focus On Develop ๐ŸคŸ๐ŸคŸ

[Swift] map, filter, reduce ๋ณธ๋ฌธ

iOS [Swift]/๊ธฐ์ดˆ๋ฅผ ํƒ„ํƒ„ํžˆ!

[Swift] map, filter, reduce

๋ˆ„๋ฆฌ๋‹ฌ์ดํ‹€ 2020. 12. 15. 22:36

 

Apple Developer Document์—์„œ map, filter, reduce์— ๋Œ€ํ•œ ์ •์˜๋ฅผ ๋ฐœ์ทŒํ•ด์˜ค๊ธด ํ–ˆ์ง€๋งŒ.. ์•„๋ฌด๋ž˜๋„ ๋‚˜๋Š” ์˜์–ด๋Š” ์–ด๋ ต๋”๋ผ. ๐Ÿ˜‚ ๐Ÿ˜‚

๋‚˜์ค‘์—๋ผ๋„ ์‰ฝ๊ฒŒ ์ฐพ์•„๋ณด๋ ค๊ณ  ํ•œ๊ธ€๋กœ ์ •๋ฆฌํ•ด๋†”์•ผ์ง€ ใ…‹ใ…‹

์ƒ์„ธ๋‚ด์šฉ : map | Apple Document

1. map

Apple Developer Document

๊ทธ๋ ‡๋‹ค๊ณ  ํ•œ๋‹ค.. 

์‰ฝ๊ฒŒ ๋งํ•˜๋ฉด ํด๋กœ์ €(์กฐ๊ฑด)๋กœ ๋ฐฐ์—ด์˜ ๊ฐ ํ•ญ๋ชฉ๋“ค์„ ๋ฐ˜์˜ํ•œ ๊ฒฐ๊ณผ๋ฌผ์„ ๊ฐ€์ง„ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

์˜ˆ์‹œ)


2. filter

Apple Developer Document

ํด๋กœ์ €(์กฐ๊ฑด)๋กœ ๋ฐฐ์—ด์˜ ๊ฐ ํ•ญ๋ชฉ๋“ค์„ ๋น„๊ตํ•˜์—ฌ ์ผ์น˜ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฌผ์„ ๊ฐ€์ง„ ์ƒˆ๋กœ์šด ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

์˜ˆ์‹œ)


3. reduce

Apple Developer Document

 

ํด๋กœ์ €(์กฐ๊ฑด)๋กœ ๋ฐฐ์—ด์˜ ๊ฐ ํ•ญ๋ชฉ๋“ค์„ ์žฌ๊ท€์ ์œผ๋กœ ์ ์šฉ์‹œ์ผœ ํ•˜๋‚˜์˜ ๊ฒฐ๊ณผ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

์ฒซ๋ฒˆ์งธ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ์ดˆ๊ธฐ๊ฐ’, ๋‘๋ฒˆ์งธ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ํด๋กœ์ €

 

์˜ˆ์‹œ) 

'iOS [Swift] > ๊ธฐ์ดˆ๋ฅผ ํƒ„ํƒ„ํžˆ!' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Swift] String.components  (0) 2020.12.18
[Swift] String.Index  (0) 2020.12.17
[Swift] String Radix๋ฅผ ํ†ตํ•œ ์ง„๋ฒ•๋ณ€ํ™˜  (0) 2020.12.16
[Swift] enumerated()  (0) 2020.12.16
[Swift] Set  (0) 2020.12.15
Comments