Coder Social home page Coder Social logo

Comments (3)

pmbruun avatar pmbruun commented on August 22, 2024

I would prefer $all or $forall, since $foreach would normally be a distribution function.

This amounts, in the general case, to TOSCA supporting lambdas, and there are two different functionalities that you may want to achieve: distribution and aggregation.

  • Both $foreach and $exists are examples of aggregation, using AND and OR respectively. You could just as well want an aggregating SUM.
  • Alternatively, you would could want distribution - a function that applies the expression to each element in a list and returns the results in a new list.

Consider now that functions $and, $or, $sum, etc. applied to a list of booleans/numbers automatically aggregate. So @and: <list-expression>* returns the conjunction of the elements of the lists (potentially skipping any null elements?), and @or: <list-expression>* returns the disjunction of the list elements.

Now if we define $each: [ <list of nodes>, <variable name>, <expression> ] as evaluating the expression for each element of the list expanded with the variable name into the expression, then you can express $forall as:

$and:
- $each: 
  - colo-group
  - X
  - $foreach: 
    - colo-group
    - Y
    - $equal:
      - [ X, RELATIONSHIP, host, TARGET, uuid ]
      - [ Y, RELATIONSHIP, host, TARGET, uuid ]

You may of course still have shorthand functions $forall and $exists for this.

from tosca-community-contributions.

lauwers avatar lauwers commented on August 22, 2024

Yes, I believe we want aggregation semantics, not distribution.
By the way, Calin raised a concern about the fact that the proposal above uses the same function syntax for defining function values (i.e. values that are obtained by evaluating a function) and for function arguments ("function pointers") to the $forall and $exists functions. Any opinions on that?

from tosca-community-contributions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.