That's a very beautiful solution.
Thank you!
On Tuesday, April 26, 2016 at 10:58:39 PM UTC+2, Josh Langsfeld wrote:
> eval works in global scope but returns its result locally, so something
> like this works easily enough:
>
> rulestrs = ["x[1] && x[2]", "x[3] || x[4]", "x[1] && (x[2] ||
eval works in global scope but returns its result locally, so something
like this works easily enough:
rulestrs = ["x[1] && x[2]", "x[3] || x[4]", "x[1] && (x[2] || x[3])"]
function evaluate(rules, boolList)
rulefuncs = [eval(parse(string("x -> ", rule))) for rule in rules]
On Tue, Apr 26, 2016 at 2:24 PM, Ali Rezaee wrote:
> Reading the rules from a file, how can I convert the strings to such
> anonymous functions?
You need to `eval` in global scope. If you are more serious about
input validation and such, you might need to have your own
Reading the rules from a file, how can I convert the strings to such
anonymous functions?
On Tuesday, April 26, 2016 at 6:48:21 PM UTC+2, Josh Langsfeld wrote:
>
> Maybe a better design would be to store the rules as anonymous functions
> rather than code strings? Something like:
>
> ```
>
I am writing code for regulated Flux Balance Analysis. I need to read some
regulatory rules from a file and predict the future state of the genes in
the network. In this example x is a vector of genes being on or off, and
each rule belongs to a reaction, i.e. if the rule is true, then the
Le mardi 26 avril 2016 à 13:22 -0400, Yichao Yu a écrit :
> On Tue, Apr 26, 2016 at 12:58 PM, Milan Bouchet-Valat wrote:
> >
> > Le mardi 26 avril 2016 à 12:52 -0400, Yichao Yu a écrit :
> > >
> > > On Tue, Apr 26, 2016 at 12:09 PM, Ali Rezaee wrote:
> > > >
> > > >
> >
On Tuesday, April 26, 2016 at 12:09:33 PM UTC-4, Ali Rezaee wrote:
>
> My objective is exactly what the code shows. I have a list of Boolean
> expressions similar to the examples in the code, and I need to evaluate
> them one by one based on x values.
> So writing a macro would be the only
On Tue, Apr 26, 2016 at 12:58 PM, Milan Bouchet-Valat wrote:
> Le mardi 26 avril 2016 à 12:52 -0400, Yichao Yu a écrit :
>> On Tue, Apr 26, 2016 at 12:09 PM, Ali Rezaee wrote:
>> >
>> >
>> > Thanks for your replies.
>> > My objective is exactly what the
Le mardi 26 avril 2016 à 12:52 -0400, Yichao Yu a écrit :
> On Tue, Apr 26, 2016 at 12:09 PM, Ali Rezaee wrote:
> >
> >
> > Thanks for your replies.
> > My objective is exactly what the code shows. I have a list of Boolean
> > expressions similar to the examples in the
On Tue, Apr 26, 2016 at 12:09 PM, Ali Rezaee wrote:
>
> Thanks for your replies.
> My objective is exactly what the code shows. I have a list of Boolean
> expressions similar to the examples in the code, and I need to evaluate them
> one by one based on x values.
> So writing
Maybe a better design would be to store the rules as anonymous functions
rather than code strings? Something like:
```
rules = [(x -> x[1] && x[2]), (x -> x[3] || x[4])] #parentheses not required
result = [rule(boolList) for rule in rules]
```
On Tuesday, April 26, 2016 at 12:09:33 PM UTC-4,
On Tuesday, April 26, 2016 at 11:38:21 AM UTC-4, Ali Rezaee wrote:
>
> Hi everyone,
>
> I am trying to run the code below. When I try the code outside of a
> function and in REPL, it runs successfully. However when I run it using a
> function it throw an error.
> Why do I get the error? and
12 matches
Mail list logo