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

Allow constrained pick #11

Open
morxa opened this issue Nov 1, 2019 · 0 comments
Open

Allow constrained pick #11

morxa opened this issue Nov 1, 2019 · 0 comments
Labels
enhancement New feature or request language

Comments

@morxa
Copy link
Collaborator

morxa commented Nov 1, 2019

Currently, we can only pick from a fixed set of objects:

pick (symbol x in { A, B, C})
  print(x)

We often want to pick an object with a certain restriction, e.g.,

pick (symbol x in {A, B, C})
  test(!exists (symbol y) on(x,y))
  grab(x)

However, this will fail because this is executed online and x is picked greedily. This can be circumvented by doing offline search, e.g.,

number function one() {
  return 1;
}
solve (5, one()) {
  pick (symbol x in {A, B, C})
    test(!exists (symbol y) on(x,y))
    grab(x)
}

But running a solver every time is a workaround that results in cluttered code. Also, as we can't nest solve, we can't nest such constrained picks.

A possible solution would be to a have a pick that accepts a formula instead of a fixed set, e.g.,

pick symbol x with !exists (symbol y) on(x, y))
  grab(x)

In conjunction with #10, this would also allow picking an object of a certain type:

pick symbol x with has_type(x, block)
  grab(x)
@vmatare vmatare added enhancement New feature or request language labels Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language
Projects
None yet
Development

No branches or pull requests

2 participants