Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⭐ sample #4478

Merged
merged 2 commits into from
Aug 5, 2024
Merged

⭐ sample #4478

merged 2 commits into from
Aug 5, 2024

Conversation

arlimus
Copy link
Member

@arlimus arlimus commented Aug 4, 2024

Introduce the sample command, which extracts a number of samples from any list or map:

> [1,2,3,4,5,6,7,8,9,10].sample(3)
sample: [
  0: 2
  1: 10
  2: 9
]

Any time you run this, you'll (most likely) get a different set of results.

> {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}.sample(3)
sample: {
  a: 1
  b: 2
  e: 5
}

Duplicates are not allowed, unless of course the original data has duplicates. Ultimately every entry is only picked once.

> users.sample(3)
users.sample: [
  0: user id = user/972/deepin-one
  1: user id = user/991/systemd-network
  2: user id = user/973/systemd-timesync
]

Introduce the `sample` command, which extracts a number of samples from any list or map:

```
> [1,2,3,4,5,6,7,8,9,10].sample(3)
sample: [
  0: 2
  1: 10
  2: 9
]
```

Any time you run this, you'll (most likely) get a different set of
results.

```
> {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}.sample(3)
sample: {
  a: 1
  b: 2
  e: 5
}
```

Duplicates are not allowed, unless of course the original data has
duplicates. Ultimately every entry is only picked once.

```
> users.sample(3)
users.sample: [
  0: user id = user/972/deepin-one
  1: user id = user/991/systemd-network
  2: user id = user/973/systemd-timesync
]

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Copy link
Contributor

github-actions bot commented Aug 4, 2024

Test Results

3 097 tests   3 096 ✅  1m 25s ⏱️
  370 suites      1 💤
   28 files        0 ❌

Results for commit 33e5c07.

♻️ This comment has been updated with latest results.

@tas50
Copy link
Member

tas50 commented Aug 4, 2024

Compliance time!

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @arlimus Nice addition.

@chris-rock chris-rock merged commit fd2a7d3 into main Aug 5, 2024
15 checks passed
@chris-rock chris-rock deleted the dom/sample branch August 5, 2024 09:39
@github-actions github-actions bot locked and limited conversation to collaborators Aug 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants