What is the difference between apply(), applyComponents(), and foreach() ?

Hi ,

What is the difference between apply(), applyComponents(), and foreach() ?

Thanks

Aswini

  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