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 ~ operation on Condition object #21

Closed
elijahbenizzy opened this issue Feb 16, 2024 · 1 comment
Closed

Allow ~ operation on Condition object #21

elijahbenizzy opened this issue Feb 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@elijahbenizzy
Copy link
Contributor

elijahbenizzy commented Feb 16, 2024

Should be as simple as flipping an inversion flag and changing hte name to have a ~

  @action(reads=["n"], writes=["n", "n_history"])
  def even(state: State) -> Tuple[dict, State]:
      result = {"n": state["n"] // 2}
      return result, state.update(**result).append(n_history=result["n"])

  @action(reads=["n"], writes=["n", "n_history"])
  def odd(state: State) -> Tuple[dict, State]:
      result = {"n": 3 * state["n"] + 1}
      return result, state.update(**result).append(n_history=result["n"])
  is_zero = expr("n == 0")
  is_even = expr("n % 2 == 0")
  application = (
      ApplicationBuilder()
      .with_state(n_history=[])
      .with_actions(
          original=Input("n"),
          even=even,
          odd=odd,
          result=Result("n_history"),
      ).with_transitions(
          (["original", "even", "odd"], "result", is_zero),
          (["original", "even", "odd"], "even", is_even),
          (["original", "even", "odd"], "odd", ~is_even),
      ).with_entrypoint("original")
      .build()
  )
  state, [result] = application.run(until=["result"])
    ```
@elijahbenizzy elijahbenizzy added the enhancement New feature or request label Feb 28, 2024
elijahbenizzy added a commit that referenced this issue May 14, 2024
Ok, this was just 15 mins of work for fun, although it does solve some
slightly annoying problems.

#21
@elijahbenizzy elijahbenizzy mentioned this issue May 14, 2024
5 tasks
elijahbenizzy added a commit that referenced this issue May 15, 2024
Ok, this was just 15 mins of work for fun, although it does solve some
slightly annoying problems.

#21
@elijahbenizzy
Copy link
Contributor Author

#183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant