Recent comments in /f/programming
butthole69 wrote
Reply to comment by flabberghaster in we've been doing a lot of "pair programming" at work lately and i'm conflicted by musou
I devised a system to control the level of carbonation in mineral water. I call it Perrier programming
butthole69 wrote
Reply to comment by eep in Game of Life with three species (gif) by twovests
what kind of class/program was this? that sounds super interesting!
musou OP wrote
Reply to comment by butthole69 in ruby lets you put an array inside itself by musou
i'll let you know when i finish .add
ing every set to this Set
i just instantiated
butthole69 wrote
Reply to ruby lets you put an array inside itself by musou
does the set of all sets contain itself?
musou OP wrote
Reply to comment by flabberghaster in ORMs are weird sometimes by musou
yeah most of the ones i have used do have the ability to execute raw SQL queries, which is how i solved the problem i had the other day. but you lose a lot of the benefit of using the ORM in the first place, you usually have to handle query pagination, input sanitization, and casting the response (which usually comes back as a 2D list of primitives) to the appropriate data structures yourself.
and just as bad, the code now has inconsistency in it. i never feel good about doing the same thing two different and incompatible ways.
hollyhoppet wrote
Reply to comment by lainproliant in soon we will be able to do math in javascript by musou
here's the patent for it. It's a little dense for me to be able to follow but maybe it has some more in-depth info?
flabberghaster wrote
Reply to ORMs are weird sometimes by musou
I'm kind of surprised they're that hard to work with. I've never used one, just hasn't come up in any of the projects i've been on; But i'd expect them to have some escape hatch. Something where you'd be able to just give it an SQL query you want to run, as a prepared statement or something, tell it some variables to put in, maybe tell it what types it would return, depending on the language, and just have it run it.
Do they not? Or is it just impractical to use somehow?
lainproliant wrote
Reply to comment by Moonside in ruby lets you put an array inside itself by musou
I actually run into these types of circular reference loops often in JS, especially when I want to serialize arbitrary objects to JSON. Some other formats such as YAML provide reference semantics and are thusly able to deal with circular references, but JSON does not.
lainproliant wrote
Reply to comment by musou in soon we will be able to do math in javascript by musou
No worries, just don't bet the farm on this one is all I'm sayin' ;)
lainproliant wrote
Reply to comment by flabberghaster in ruby lets you put an array inside itself by musou
What you're actually doing in Python when you put a list into itself is to put a reference to the list into itself.
L = []
L.append(L)
L[0] is L # True
Python and Ruby arrays are heterogenous, unlike in C++, where strong typing forces us to define a common type for objects contained in the same collection. There's no way to do this with the STL <vector>
, but you could do this with an object system, for example Qt, where all "Q" objects derive from QObject:
QVector<QObject*> objectVector;
objectVector.append(&objectVector);
musou OP wrote
Reply to comment by lainproliant in soon we will be able to do math in javascript by musou
not that i have found, that's why i'm not taking this super seriously yet. i don't know much about EE or hardware stuff. just hoping to learn more from other sources.
lainproliant wrote
Reply to soon we will be able to do math in javascript by musou
Does the author offer any sort of arXiv or other link to a research paper about this? So far, it's just them saying "hey I found this thing!" and gives a very basic and non-rigorous explanation of the "innovative" solution. Snake oil until proven otherwise.
twovests wrote
Reply to soon we will be able to do math in javascript by musou
that tfw when :')
musou OP wrote
Reply to comment by flabberghaster in ruby lets you put an array inside itself by musou
yeah! this is a good explanation of why it works. i'm mostly interested in figuring out ways to use recursive arrays that are practically useful, or at least interesting. but i still have nothing so far ._.
flabberghaster wrote
Reply to comment by jorty in we've been doing a lot of "pair programming" at work lately and i'm conflicted by musou
I made robottic fruits you can control with an Arduino. This allows pear programming.
flabberghaster wrote
Reply to comment by musou in ruby lets you put an array inside itself by musou
I think that it's basically a special case of how in those languages it's easy to assign a reference to things. Adding a list to itself is not really that different than assigning a reference to an object as a member of itself. For instance in python you can do:
class Node:
__init__(self, value, next=None):
self.value = value
self.next = next
def main():
head = Node("last")
tail = head
for i in range(10): head = Node(i, head)
tail.next = head
And this creates a cyclic linked list. You could just as easily assign a = Node(9); a.next = a
and have the graph have only one vertex. It's the same principle with adding a list to itself: you're not actually adding the list to itself; rather you're putting a reference to the container, inside the container. Like writing down the location of a bank on a slip of paper, then putting that slip of paper inside a safe deposit box stored inside the same bank.
musou OP wrote
Reply to comment by flabberghaster in ruby lets you put an array inside itself by musou
it's cool to know that python can do it too. i guess i should make a list of which languages can and can't do it.
it's super fun to think about, but i still can't come up with any way in which i could exploit it to do something fun or useful in order to make straightlaced programmers care about it
flabberghaster wrote
Reply to ruby lets you put an array inside itself by musou
Turns out python can too. I was trying to think of how to get c++ to do it, but i could only think if how to do it using void pointers since to add something to a container that container would have to be a container of its own type which I can't think how to do off the top of my head.
Interesting problem.
Moonside wrote
Reply to ruby lets you put an array inside itself by musou
scary
lainproliant wrote
Reply to Game of Life with three species (gif) by twovests
Wow, It's absolutely mezmerizing. Thanks for sharing!
lainproliant wrote
Reply to comment by lainproliant in So what project are you working on? by Moonside
https://github.com/lainproliant/lost-levels
Run submodules.sh
to pull down the submodules, then make
to build. Requires sdl2 and sdl2-image.
There's two demos: quadtree
that shows the breakdown of a quadtree that would be used for collision detection, and simple
that I use as a benchmarking tool to see how many sprites I can get on the screen before framerate starts to suffer.
lainproliant wrote
Reply to comment by twovests in So what project are you working on? by Moonside
It's going through a rewrite, but I can share with you the old version.
eep wrote
Reply to comment by twovests in Game of Life with three species (gif) by twovests
aaa it’s been ages but I’ll try! it was half fun and half frustrating mostly cause none of us had programming backgrounds. we had an instructor who taught programming, but he did not have a design background so it’s a bunch of misunderstandings lol
the basic idea was to ‘grow’ a city using cellular automata but also avoiding specific areas like historical buildings, places of culture (this didn’t work because our general lack of skills, which resulted to rigidity) there’s also the lack of connectivity (since cells in cellular automata ‘die’ and don’t physically connect while they are alive) so there was the introduction of other systems like lindenmeyer system to permit branching
the result was somewhat similar to the cards bouncing around and intertwining when you finish a game in solitaire
twovests OP wrote
Reply to comment by musou in Game of Life with three species (gif) by twovests
I did some research (after finishin all this) and there's some cool ones:
butthole69 wrote
Reply to `curl parrot.live` by musou