Function return types

Hi, I’m experimenting with the ability to write functions and call them.

I have:

CREATE QUERY systemq(VERTEX<system_> sys) FOR GRAPH ty RETURNS (Set<VERTEX<system_>>) 

{ 

  Start={sys};

   RETURN Start;

}

Creating a query that uses this function and prints the results just shows the primary_id however:

CREATE QUERY systemqPrintFromQ(VERTEX<system_> sys) FOR GRAPH ty 

{ 

  PRINT systemq(sys);

}

RESULT:

[

  {

    "systemq(sys)": [

      "WOOL03"

    ]

  }

]

Whereas a query that prints it directly shows the whole object:

CREATE QUERY systemqPrint(VERTEX<system_> sys) FOR GRAPH ty 

{ 

  Start={sys};

  PRINT Start;

}

RESULT:

[

  {

    "Start": [

      {

        "v_id": "WOOL03",

        "v_type": "system_",

        "attributes": {}

      }

    ]

  }

]
```
Is there a way to pass all the parameters back?

Is there a way to do so without adding a mapping step, eg via function composition and lazy evaluation?

Cheers,

Rene

Hi Rene,

To workaround this, you can change your main query to something like this :

create query systemqPrintFromQ(vertex<system_> sys) for graph ty {
SetAccum @@returned;

@@returned = systemq(sys);
printthis = @@returned;

print printthis;

}

This way, you pass the the vertex back into the main query, and activate it, allowing you to print out all of its attributes.

Thanks,
Kevin

Thanks for the response Kevin.

Can you please explain what you mean by “activate”?

IE does putting a variable into an global accumulator “activate” it? What is the difference between activated and non activated variables?

Cheers,

Rene

Sorry if this confused you, I just mean it is stored into memory for immediate use.

Vertices stored in vertex sets will print all attributes - and vertices stored in Set Accumulators will print the vertex id.

Thanks,

Kevin