Skip to Content.
Sympa Menu

k-user - [K-user] function to get list of Ancestors

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[K-user] function to get list of Ancestors


Chronological Thread 
  • From: Omar Duhaiby <3omarz AT gmail.com>
  • To: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Cc: "Musab A. AlTurki" <musab AT kfupm.edu.sa>
  • Subject: [K-user] function to get list of Ancestors
  • Date: Sat, 15 Nov 2014 14:53:13 +0300
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hello,

I have in my configuration a cell for the thread's ID and another for its parent's ID, called respectively <tid> and <parentId>. I use this to make a tree of threads.

My question is: How do I make a function that will return a list of thread IDs of all the ancestors of a certain thread? Here is what I did:

    rule
        <k> ancestorsOf(Tid:Int) => ListItem(Pid) ancestorsOf(Pid) ...</k>
        <thread>... <tid> Tid </tid> <parentId> Pid </parentId> ...</thread>
        <thread>... <tid> Pid </tid> ...</thread>
    rule ancestorsOf(0) => .List

I'm using it in a rule like so:
when AncestorId in ancestorsOf(MyId)

Also, how do I define it correctly in the syntax to give it a type List so that the compiler doesn't complain about parsing ambiguity between it being a List or a Set when seeing the 'in' operator?

Thank you


  • [K-user] function to get list of Ancestors, Omar Duhaiby, 11/15/2014

Archive powered by MHonArc 2.6.16.

Top of Page