I have two dictionaries.The first has a key of a symbol and value a list of symbols beingitself plus its related parent.i.eopbpj| opbpj fnadbfnadb| fnadb hadmchadmc| hadmc jjjoajjjoa| jjjoa aglagaglag| aglag The second is a dictionary linking symbols with their related parent.opbpj| fnadbfnadb| hadmchadmc| jjjoajjjoa| aglagaglag| I want to take the last item in the each of the items in the firstdictionary and append its parent if it has one.After appending the parent I also want to check if that also has aparent and append that.Result ofopbpj| opbpj fnadb hadmc jjjoa aglag fnadb| fnadb hadmc jjjoa aglag hadmc| hadmc jjjoa aglag jjjoa| jjjoa aglag aglag| aglag `In this example they are in order but thats not an assumption I canmake.Any advice would be appreciated.Thanks,Daniel
executable input and simple to follow examples are preferred…
you only need one dictionary
q)d:abcde!bcde
q)scan[d]each d
a| bcde b|cde c|de
d| e
e| ,`
=A0 Attila
Thanks Attila.list:distinct 1000?5dict:list!1_list,@[scan[dict] each dict;key dict;{,[y;x]};key dict]This is what I am now using as I need the original at the key at thestart also.On Oct 11, 3:38?pm, Attila Vrabecz <attila.vrab…> wrote:> executable input and simple to follow examples are preferred…> you only need one dictionary>> q)d:abcde!bcde> q)scan[d]each d> a| bcde> b| cde> c| de> d| e> e| ,> ? Attila>>>>>>>> On Tue, Oct 11, 2011 at 8:13 AM, Daniel <cas...> wrote:> > I have two dictionaries.>> > The first has a key of a symbol and value a list of symbols being> > itself plus its related parent.>> > i.e>> > opbpj| opbpj fnadb> > fnadb| fnadb hadmc> > hadmc| hadmc jjjoa> > jjjoa| jjjoa aglag> > aglag| aglag >> > The second is a dictionary linking symbols with their related parent.>> > opbpj| fnadb> > fnadb| hadmc> > hadmc| jjjoa> > jjjoa| aglag> > aglag| >> > I want to take the last item in the each of the items in the first> > dictionary and append its parent if it has one.> > After appending the parent I also want to check if that also has a> > parent and append that.>> > Result of>> > opbpj| opbpj fnadb hadmc jjjoa aglag > > fnadb| fnadb hadmc jjjoa aglag > > hadmc| hadmc jjjoa aglag > > jjjoa| jjjoa aglag > > aglag| aglag >> > In this example they are in order but thats not an assumption I can> > make.>> > Any advice would be appreciated.>> > Thanks,> > Daniel>> > –> >
Submitted via Google Groups</cas…></attila.vrab…>
key[d],'scan[d]each d:{x!next x} -1000?`5
=A0 Attila
d:opbpjfnadbhadmcjjjoaaglag!(opbpjfnadb;fnadbhadmc;hadmcjjjoa;jjjoaaglag;aglag)d2:opbpjfnadbhadmcjjjoaaglag!(fnadb;hadmc;jjjoa;aglag;){x, raze {[y] l:();while[not null y;y:d2[y];l,:y];:l}each -1#x}each dOn Oct 11, 12:13?pm, Daniel <cas...> wrote:> I have two dictionaries.>> The first has a key of a symbol and value a list of symbols being> itself plus its related parent.>> i.e>> opbpj| opbpj fnadb> fnadb| fnadb hadmc> hadmc| hadmc jjjoa> jjjoa| jjjoa aglag> aglag| aglag >> The second is a dictionary linking symbols with their related parent.>> opbpj| fnadb> fnadb| hadmc> hadmc| jjjoa> jjjoa| aglag> aglag| >> I want to take the last item in the each of the items in the first> dictionary and append its parent if it has one.> After appending the parent I also want to check if that also has a> parent and append that.>> Result of>> opbpj| opbpj fnadb hadmc jjjoa aglag > fnadb| fnadb hadmc jjjoa aglag > hadmc| hadmc jjjoa aglag > jjjoa| jjjoa aglag > aglag| aglag >> In this example they are in order but thats not an assumption I can> make.>> Any advice would be appreciated.>> Thanks,> Daniel</cas…>