I concur with David. If you need to, simply create a specialised version based on the ximage code in the IPL. I have also code that is applicable to the classes of Unicon that I'll try to dig up. This code was based on feedback from both Clinton and Jafar some time ago.
It the end, you can then write your own versions of write and writes that will override the system provided routines and print out any value that is supplied to the procedures in any format you require. As soon as I find my code, I'll make it available to all. regards Bruce Rennie On 11/03/14 09:28, [email protected] wrote: > Ximage also addresses this. Perhaps not as nicely. > > Sent from my BlackBerry 10 smartphone on the Rogers network. > Original Message > From: Michael Glass > Sent: Monday, March 10, 2014 5:59 PM > To: Robert Heckendorn; Jafar Al-Gharaibeh > Cc: Clinton Jeffery; David Gamey; Unicon group > Subject: Re: [Unicon-group] Some unicon code > > Your desire to recursively traverse structures opens up several issues, viz: > > -- The order of traversing structures: depth-first or breadth first. > -- Do you want to render the same structure twice > -- How to handle circular structures: A points to B points to A... > > Here are the same structure twice and circularity questions: > > L1 := ['a', 'b'] > L2 := [L1, L1] > put(L2, L2) > writeany(L2) > > How do you want L2 to display? Do you want to render and print L1 > multiple times, even if it is a big complicated mess? What about the > L2-inside-L2 problem? > > You might want to look at the Image() function in the Icon library. Many > (!) years ago I beefed it up to do the kind of thing you are talking > about. It is a bit messy, partly because there is an option to display > tree structure in indented fashion. It handles only lists, records, > sets, and tables. In other words, it handles only pre-Unicon code. > Particularly you would miss the class system, I think. > > The Image() function handles the same-structure-twice and circularity > problems by generating labels for structures, which is what the built-in > image() function does. The above would print something like this (as I > recall): > L2:[ L1:['a', 'b'], L1, L2] > > -- Michael Glass > Valparaiso University > > On 03/10/2014 03:10 PM, Robert Heckendorn wrote: >> Couple of nice solutions! Educational , interesting, elegant. Thanks! >> >> >> Here is the actual problem: >> I want the write() and writes() funcitons to take arbitrary typed >> objects and print something >> reasonable. So writeany() could take a list of lists for instance. The >> solutions so far do not >> assume the components can be printed by writes. What if this needs to >> be a recursive application >> of writeany for lists so each elem in the list is also printed with >> writeany. That gets in the way of >> these two solutions for various reasons. Anyone want to speculate on >> an elegant method if the >> function must invoke itself for each element until things writeable with >> writes are found. >> >> cheers, >> >> ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Unicon-group mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/unicon-group
