Name: Anonymous 2014-01-20 18:58
what is you're opinion on foreache loops?
i don't like em cuz they ache in the fore
i don't like em cuz they ache in the fore
for
unless you've got a damn good reason.foreach
when I want to Map
. foreach
is a control construct map
is a function.
int pointless;
for (int i = 0; i % 13 != 0; i += 3) {
pointless = i;
}
foreach
with something like break
and return
or a "Knuth style" mutli-body foreach
construct with by
clauses. yield
) and you'll get a generator, which is a stream, but not a loop.
for (it = begin(collection); it.has_next(); it.advance())
obviously the for loop itself isn't the stream, the iterator is the stream, the for loop is just the consumer of the streamYes. obviously.
foreach
and other control constructs. #include <super/special.h>
int main(void)
{
return yay();
}
In opposition to many cake eaters from my university, I believe that ideas behind Sglib are good because of my former research on modern (and generic) programming languages and because of my current work on a refactoring browser for C.A page about a data structure ``library''* isn't the place to put snide comments about former classmates, well-deserved though that comment may be. That's not a condemnation of the code, but given the quality of other writings/projects I've seen from authors who made such comments, I was reluctant to trust the vague technical claims that this author makes. Still, this would not be significant in my overall choice to use the library, were I to make one.
SGLIB_LIST_LEN
. Linear time? What the fuck? If that's the price I have to pay for not linking against anything, no thank you.SGLIB_LIST_LEN. Linear time? What the fuck? If that's the price I have to pay for not linking against anything, no thank you.
struct
. That's kind of what they are for: grouping associated data together.
some_list = make_list(1, 2, 3, 4, 5, 6, 7, 8);
tail = nth_tail(some_list, 4);
append(tail, make_list(9, 10, 11, 12));
append
also update the length of some_list
, as it needs to do? struct linked_list {
struct linked_list *list_this_is_a_subset_of;
struct linked_list **lists_that_are_sublists_of_this_list;
size_t length;
struct linked_list_node *head;
}
NULL
next and that the list to be appended isn't a sublist of anything else, concatenates the two together, walks up to the parent of all lists, then walks down all sublists, fixing the lengths as appropriate. nth_tail likewise adds an entry to lists_that_are_sublists_of_this_list (for which a few ancillary variables are omitted to keep the struct cleaner, fill them in depending on how memory-aggressive you want to be) so that it doesn't get left un-updated when its sibling has a list appended to it. list_this_is_a_subset_of
also needs to be an array of pointers.I don't know of any data structure with as many uses as linked lists.
when ``list'' means ``linked list''
int
, float
, char
, some_struct
etc. which both treat them as some thing (e.g. stacks or finite sequences) or which give a foundational vocabulary for vocabularies at higher level in a stratified design.2) You are writing a program where a data role maps to something that is not a linked listShould be
2) You are writing a program where all data roles map to things that are not linked lists
sort(float_node_t*)
, sort(edgel_node_t*)
, sort(glyph_node_t*)
etc. every time you want to sort a finite sequence of somethings represented by a linked list, is a good way to spend your time when you know it can be automated? every time you want to sort a finite sequence of somethings represented by a linked listSo it's mind boggling that you would then write:
Why would you think it's a good idea to implement only one sorting algorithm for all data structures in your programI mentioned one data structure!; Generecity across data structures isn't what's being discussed.
function broadcast(name,data,conn){
if (!data) data={};
data.type = name;
conns.forEach(function (conn2) { if(conn2!=conn) conn2.send(data); });
}