archives

Replace heads function in Lisp

Hello All,
I have recently started learning Lisp and currently I am struggling to design a function replace-heads, which takes a list-of-lists as one argument and an atom as the second, and returns a list-of-lists in which the first element of each component list has been replaced with the atom passed in. So, for example, (replace-heads '((a b c) (d e) (f g h)) 'x) returns ((x b c) (x e) (x g h)).

I am not able to apply tree recursion method when actually replacing the first element in the last sub list for a given parent node.

Can somebody please help?

Thanks,
AceKnocks

The Disciplined Disciple Compiler

Disciple is an explicitly lazy dialect of Haskell which includes:
  • first class destructive update of arbitrary data.
  • computational effects without the need for state monads.
  • type directed field projections.
All this and more through the magic of effect typing.

The wiki page has more information, unfortunately there's no paper yet summarizing the ideas and results. Their effect system is quite interesting. Some of the ideas recently discussed here are implemented in Disciple.

via Haskell Cafe

Relational rather than hierarchical OO packaging?

Nothing stunning here, just a basic/simplistic question -

Assuming relational better than hierarchical, for "visibility" of things in languages, are there / could there be a successful approach to visibility of things which is relational, not hierarchical?

C++ has the "friend" visibility keyword, Java and C# don't seem to have a cross-cutting visibility tool. Does C++'s "friend" suffice, or does it have too much of a preference of hierarchical over relational, and/or does it have some land-mine drawbacks (I mean besides the standard chances of abuse)? I guess I was always just queasy with it e.g.

If encountering friend functions for the first time, you might feel slightly uneasy since they seem to violate encapsulation. This feeling may stem from the fact that a friend function is not strictly a member of the class.

By thinking of a friend function as part of the class’s public interface, you can get a better understanding of how friends work. From a design perspective, friends can be treated in a similar way to public member functions. The concept of a class interface can be extended from public members to include friend functions and friend classes.