{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift-evolution/pulls/comments/183483719","pull_request_review_id":114490834,"id":183483719,"diff_hunk":"@@ -0,0 +1,70 @@\n+# `count(where:)`\n+\n+* Proposal: [SE-NNNN](NNNN-filename.md)\n+* Authors: [Soroush Khanlou](https://github.com/khanlou)\n+* Review Manager: TBD\n+* Status: **Awaiting implementation**\n+\n+## Introduction\n+\n+While Swift's `Sequence` models brings a lot of niceties that we didn't have access to in Objective-C, like `map` and `filter`, there are other useful operations on sequences that the standard library doesn't support yet. One current missing operation is  `count(where:)`, which counts the number of elements in a `Sequence` that pass some test.\n+\n+Swift-evolution thread: [`count(where:)` on Sequence](https://forums.swift.org/t/count-where-on-sequence/11186)\n+\n+## Motivation\n+\n+Counting the number of objects that pass a test has a wide range of uses in many domains. However, Swift currently doesn't give its users a simple way to perform this operation. While the behavior can currently be approximated with a `filter` and a `count`, this approach creates an intermediate array which it immediately discards. This is a bit wasteful.\n+\n+    [1, 2, 3, -1, -2].filter({ $0 > 0 }).count // => 3","path":"proposals/XXXX-count-where.md","position":18,"original_position":18,"commit_id":"3aa08781136698651b4d2dae7e2c3054bf100320","original_commit_id":"3aa08781136698651b4d2dae7e2c3054bf100320","user":{"login":"BasThomas","id":4190298,"avatar_url":"https://avatars0.githubusercontent.com/u/4190298?v=4","gravatar_id":"","url":"https://api.github.com/users/BasThomas","html_url":"https://github.com/BasThomas","followers_url":"https://api.github.com/users/BasThomas/followers","following_url":"https://api.github.com/users/BasThomas/following{/other_user}","gists_url":"https://api.github.com/users/BasThomas/gists{/gist_id}","starred_url":"https://api.github.com/users/BasThomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BasThomas/subscriptions","organizations_url":"https://api.github.com/users/BasThomas/orgs","repos_url":"https://api.github.com/users/BasThomas/repos","events_url":"https://api.github.com/users/BasThomas/events{/privacy}","received_events_url":"https://api.github.com/users/BasThomas/received_events","type":"User","site_admin":false},"body":"You can, instead of adding the four spaces, wrap these in backticks (\\`\\`\\`) and add syntax highlighting (\\`\\`\\`swift on the first line)","created_at":"2018-04-23T17:54:19Z","updated_at":"2018-04-23T17:54:19Z","html_url":"https://github.com/apple/swift-evolution/pull/840#discussion_r183483719","pull_request_url":"https://api.github.com/repos/apple/swift-evolution/pulls/840","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/comments/183483719"},"html":{"href":"https://github.com/apple/swift-evolution/pull/840#discussion_r183483719"},"pull_request":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/840"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift-evolution/pulls/840","id":183464411,"html_url":"https://github.com/apple/swift-evolution/pull/840","diff_url":"https://github.com/apple/swift-evolution/pull/840.diff","patch_url":"https://github.com/apple/swift-evolution/pull/840.patch","issue_url":"https://api.github.com/repos/apple/swift-evolution/issues/840","number":840,"state":"open","locked":false,"title":"Add a proposal for count(where:)","user":{"login":"khanlou","id":850492,"avatar_url":"https://avatars3.githubusercontent.com/u/850492?v=4","gravatar_id":"","url":"https://api.github.com/users/khanlou","html_url":"https://github.com/khanlou","followers_url":"https://api.github.com/users/khanlou/followers","following_url":"https://api.github.com/users/khanlou/following{/other_user}","gists_url":"https://api.github.com/users/khanlou/gists{/gist_id}","starred_url":"https://api.github.com/users/khanlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khanlou/subscriptions","organizations_url":"https://api.github.com/users/khanlou/orgs","repos_url":"https://api.github.com/users/khanlou/repos","events_url":"https://api.github.com/users/khanlou/events{/privacy}","received_events_url":"https://api.github.com/users/khanlou/received_events","type":"User","site_admin":false},"body":"This is a proposal for `count(where:)`. \r\n\r\nPitch thread: https://forums.swift.org/t/count-where-on-sequence/11186\r\n\r\nRecommended implementation: https://github.com/apple/swift/pull/16099","created_at":"2018-04-23T15:02:47Z","updated_at":"2018-04-23T17:54:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e0d3418555f6839477cd34e9d516c0f4d30c47f6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift-evolution/pulls/840/commits","review_comments_url":"https://api.github.com/repos/apple/swift-evolution/pulls/840/comments","review_comment_url":"https://api.github.com/repos/apple/swift-evolution/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift-evolution/issues/840/comments","statuses_url":"https://api.github.com/repos/apple/swift-evolution/statuses/3aa08781136698651b4d2dae7e2c3054bf100320","head":{"label":"khanlou:count-where","ref":"count-where","sha":"3aa08781136698651b4d2dae7e2c3054bf100320","user":{"login":"khanlou","id":850492,"avatar_url":"https://avatars3.githubusercontent.com/u/850492?v=4","gravatar_id":"","url":"https://api.github.com/users/khanlou","html_url":"https://github.com/khanlou","followers_url":"https://api.github.com/users/khanlou/followers","following_url":"https://api.github.com/users/khanlou/following{/other_user}","gists_url":"https://api.github.com/users/khanlou/gists{/gist_id}","starred_url":"https://api.github.com/users/khanlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khanlou/subscriptions","organizations_url":"https://api.github.com/users/khanlou/orgs","repos_url":"https://api.github.com/users/khanlou/repos","events_url":"https://api.github.com/users/khanlou/events{/privacy}","received_events_url":"https://api.github.com/users/khanlou/received_events","type":"User","site_admin":false},"repo":{"id":98064094,"name":"swift-evolution","full_name":"khanlou/swift-evolution","owner":{"login":"khanlou","id":850492,"avatar_url":"https://avatars3.githubusercontent.com/u/850492?v=4","gravatar_id":"","url":"https://api.github.com/users/khanlou","html_url":"https://github.com/khanlou","followers_url":"https://api.github.com/users/khanlou/followers","following_url":"https://api.github.com/users/khanlou/following{/other_user}","gists_url":"https://api.github.com/users/khanlou/gists{/gist_id}","starred_url":"https://api.github.com/users/khanlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khanlou/subscriptions","organizations_url":"https://api.github.com/users/khanlou/orgs","repos_url":"https://api.github.com/users/khanlou/repos","events_url":"https://api.github.com/users/khanlou/events{/privacy}","received_events_url":"https://api.github.com/users/khanlou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khanlou/swift-evolution","description":"This maintains proposals for changes and user-visible enhancements to the Swift Programming Language.","fork":true,"url":"https://api.github.com/repos/khanlou/swift-evolution","forks_url":"https://api.github.com/repos/khanlou/swift-evolution/forks","keys_url":"https://api.github.com/repos/khanlou/swift-evolution/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khanlou/swift-evolution/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khanlou/swift-evolution/teams","hooks_url":"https://api.github.com/repos/khanlou/swift-evolution/hooks","issue_events_url":"https://api.github.com/repos/khanlou/swift-evolution/issues/events{/number}","events_url":"https://api.github.com/repos/khanlou/swift-evolution/events","assignees_url":"https://api.github.com/repos/khanlou/swift-evolution/assignees{/user}","branches_url":"https://api.github.com/repos/khanlou/swift-evolution/branches{/branch}","tags_url":"https://api.github.com/repos/khanlou/swift-evolution/tags","blobs_url":"https://api.github.com/repos/khanlou/swift-evolution/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khanlou/swift-evolution/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khanlou/swift-evolution/git/refs{/sha}","trees_url":"https://api.github.com/repos/khanlou/swift-evolution/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khanlou/swift-evolution/statuses/{sha}","languages_url":"https://api.github.com/repos/khanlou/swift-evolution/languages","stargazers_url":"https://api.github.com/repos/khanlou/swift-evolution/stargazers","contributors_url":"https://api.github.com/repos/khanlou/swift-evolution/contributors","subscribers_url":"https://api.github.com/repos/khanlou/swift-evolution/subscribers","subscription_url":"https://api.github.com/repos/khanlou/swift-evolution/subscription","commits_url":"https://api.github.com/repos/khanlou/swift-evolution/commits{/sha}","git_commits_url":"https://api.github.com/repos/khanlou/swift-evolution/git/commits{/sha}","comments_url":"https://api.github.com/repos/khanlou/swift-evolution/comments{/number}","issue_comment_url":"https://api.github.com/repos/khanlou/swift-evolution/issues/comments{/number}","contents_url":"https://api.github.com/repos/khanlou/swift-evolution/contents/{+path}","compare_url":"https://api.github.com/repos/khanlou/swift-evolution/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khanlou/swift-evolution/merges","archive_url":"https://api.github.com/repos/khanlou/swift-evolution/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khanlou/swift-evolution/downloads","issues_url":"https://api.github.com/repos/khanlou/swift-evolution/issues{/number}","pulls_url":"https://api.github.com/repos/khanlou/swift-evolution/pulls{/number}","milestones_url":"https://api.github.com/repos/khanlou/swift-evolution/milestones{/number}","notifications_url":"https://api.github.com/repos/khanlou/swift-evolution/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khanlou/swift-evolution/labels{/name}","releases_url":"https://api.github.com/repos/khanlou/swift-evolution/releases{/id}","deployments_url":"https://api.github.com/repos/khanlou/swift-evolution/deployments","created_at":"2017-07-22T23:49:31Z","updated_at":"2018-04-23T14:51:51Z","pushed_at":"2018-04-23T15:00:37Z","git_url":"git://github.com/khanlou/swift-evolution.git","ssh_url":"git@github.com:khanlou/swift-evolution.git","clone_url":"https://github.com/khanlou/swift-evolution.git","svn_url":"https://github.com/khanlou/swift-evolution","homepage":"https://apple.github.io/swift-evolution/","size":3245,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"d30c5ae90e2e289cd13b2e84c9485078da99841e","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":45497910,"name":"swift-evolution","full_name":"apple/swift-evolution","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift-evolution","description":"This maintains proposals for changes and user-visible enhancements to the Swift Programming Language.","fork":false,"url":"https://api.github.com/repos/apple/swift-evolution","forks_url":"https://api.github.com/repos/apple/swift-evolution/forks","keys_url":"https://api.github.com/repos/apple/swift-evolution/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift-evolution/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift-evolution/teams","hooks_url":"https://api.github.com/repos/apple/swift-evolution/hooks","issue_events_url":"https://api.github.com/repos/apple/swift-evolution/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift-evolution/events","assignees_url":"https://api.github.com/repos/apple/swift-evolution/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift-evolution/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift-evolution/tags","blobs_url":"https://api.github.com/repos/apple/swift-evolution/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift-evolution/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift-evolution/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift-evolution/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift-evolution/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift-evolution/languages","stargazers_url":"https://api.github.com/repos/apple/swift-evolution/stargazers","contributors_url":"https://api.github.com/repos/apple/swift-evolution/contributors","subscribers_url":"https://api.github.com/repos/apple/swift-evolution/subscribers","subscription_url":"https://api.github.com/repos/apple/swift-evolution/subscription","commits_url":"https://api.github.com/repos/apple/swift-evolution/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift-evolution/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift-evolution/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift-evolution/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift-evolution/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift-evolution/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift-evolution/merges","archive_url":"https://api.github.com/repos/apple/swift-evolution/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift-evolution/downloads","issues_url":"https://api.github.com/repos/apple/swift-evolution/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift-evolution/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift-evolution/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift-evolution/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift-evolution/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift-evolution/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift-evolution/deployments","created_at":"2015-11-03T21:49:37Z","updated_at":"2018-04-23T14:28:12Z","pushed_at":"2018-04-23T15:02:48Z","git_url":"git://github.com/apple/swift-evolution.git","ssh_url":"git@github.com:apple/swift-evolution.git","clone_url":"https://github.com/apple/swift-evolution.git","svn_url":"https://github.com/apple/swift-evolution","homepage":"https://apple.github.io/swift-evolution/","size":3253,"stargazers_count":8588,"watchers_count":8588,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1392,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":1392,"open_issues":24,"watchers":8588,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/840"},"html":{"href":"https://github.com/apple/swift-evolution/pull/840"},"issue":{"href":"https://api.github.com/repos/apple/swift-evolution/issues/840"},"comments":{"href":"https://api.github.com/repos/apple/swift-evolution/issues/840/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/840/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift-evolution/pulls/840/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift-evolution/statuses/3aa08781136698651b4d2dae7e2c3054bf100320"}},"author_association":"NONE"}}
{"actor":{"display_login":"BasThomas"}}