Difference b/w apply(),applyComponent,For Each loop

Hi ,

 

Can anyone share some good example to differentiate b/w apply(),applyComponent,For Each loop.

 

Please don't share any documentation link as i am not getting clarity by seeing that.

 

If possible plz use any small dataset to give an example. This always confuse which one i should use on what scenario.

 

  Discussion posts and replies are publicly visible

Parents
  • apply(): Call a function or a rule for each time which you have specified in a list.
    ex:

    apply(
    sum(1,_),
    {1,2,3,4}
    )

    function will execute 4 times because length of list is 4,in place of sum() you can cal your own rules.

    apply() cannot be used with rules or functions that store local data, including rules using load() and certain SAIL components.
    In these cases, we have to use a!applyComponents().


    a!foreach() is also a looping function
    in previous versions it was not their so we have to go with apply() and a!applyComponents(),
    from 17.2 version we have a!foreach() ,it will do every thing which apply() and a!applyComponents() does.
Reply
  • apply(): Call a function or a rule for each time which you have specified in a list.
    ex:

    apply(
    sum(1,_),
    {1,2,3,4}
    )

    function will execute 4 times because length of list is 4,in place of sum() you can cal your own rules.

    apply() cannot be used with rules or functions that store local data, including rules using load() and certain SAIL components.
    In these cases, we have to use a!applyComponents().


    a!foreach() is also a looping function
    in previous versions it was not their so we have to go with apply() and a!applyComponents(),
    from 17.2 version we have a!foreach() ,it will do every thing which apply() and a!applyComponents() does.
Children
No Data