prosyslab-classroom / cs348-information-security

61 stars 10 forks source link

[Question][Hw0-2] Sigma function of calculator.ml #207

Closed adzaky15 closed 1 year ago

adzaky15 commented 1 year ago

Name: Akhdan Dzaky Maulana

Hello! I'm doing calculator.ml, and I got stuck on the Sigma(e1, e2, e3) -> part.

Should I add "env" map to the calculator? Or should I find a way to convert e3 into a function?

pingpingy1 commented 1 year ago

I think you can write a helper function that takes the environment into account, and then use it inside the calculator function.

ICubE- commented 1 year ago

There would be two solutions:

  1. Make a helper function that has an environment argument calc_aux (expr) (env) and save the value of X in the environment.
  2. Since only one variable named X exists, substitute all X in e3, except for internal sigma.

First one is more general solution, but second one is easier to implement.

bonjune commented 1 year ago

I did it iterating all possible values of X when evaluating Sigma expression. :)

KihongHeo commented 1 year ago

@adzaky15 does the above comments solve your problem? Please close this issue if so.