Programming, computers, etc. [Serious]
- Dreams
- ASDF High Priest

- Posts: 2306
- Joined: Tue Nov 29, 2011 7:04 pm
- Location: STOP STALKING ME! I'M INSECURE!
- Contact:
Re: Programming, computers, etc. [Serious]
Now that's just contradictory 
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I think it will get more people to try Linux out (though live CDs are pretty cool, too).
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
I've been spending the good part of today on learning linux bash scripting, I'm writing a test tomorrow..

- Dreams
- ASDF High Priest

- Posts: 2306
- Joined: Tue Nov 29, 2011 7:04 pm
- Location: STOP STALKING ME! I'M INSECURE!
- Contact:
Re: Programming, computers, etc. [Serious]
Good. Don't destroy system files.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Bash scripting can be really powerful.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
My flash sig seems to not work properly all of a sudden.. it stops between the last and the first image, i think. I'm just gonna change it to a simple image, i guess, I don't bother with bugs that come out of nowhere..

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Maybe an update to Flash?
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
i'm writing a tough Assembly test tomorrow, wish me kind registers!
Code: Select all
mov bed,atomtengeralattjaro
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
May your registers behave themselves.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
and so they did
Fortunately we had enough time, and I think I passed. Only for some reason when the program drew a triangle, it also drew a bunch of other lines in other places.. :S i guess i lost my way in the video memory somehow.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
It's easy to get lost in assembly.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I feel bad double posting, but I found out something interesting today.
First, the known facts:
In Python, everything has a "truthiness" to it. That is, logically, everything is either True or False. If it's None, False, 0, 0.0, or the length of it is 0, it's considered to be False. Everything else is True (including functions and classes).
What I found out:
The logical "and" and "or" in Python don't always return True or False. They return one of the operands. "and" returns the first operand if it's "False-like" and the second one otherwise. "or" returns the first operand if it's "True-like" and the second one otherwise. Sure, you can "cast" it as a bool, but if you don't, it can lead to some interesting side effects.
Examples: is "Bob"
is 5
First, the known facts:
In Python, everything has a "truthiness" to it. That is, logically, everything is either True or False. If it's None, False, 0, 0.0, or the length of it is 0, it's considered to be False. Everything else is True (including functions and classes).
What I found out:
The logical "and" and "or" in Python don't always return True or False. They return one of the operands. "and" returns the first operand if it's "False-like" and the second one otherwise. "or" returns the first operand if it's "True-like" and the second one otherwise. Sure, you can "cast" it as a bool, but if you don't, it can lead to some interesting side effects.
Examples:
Code: Select all
5 and "Bob"Code: Select all
5 or "Bob"BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
this truthiness thingy is spooky. Do you know any scenarios where this can be used? i think it would just confuse me, but it does seem interesting.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Well, I don't know exactly when it would be used... It behaves exactly the way that you would expect it to in if statements and while loops. The truthiness thing exists in C/++, too. You can do "while(5){doStuffThatHopefullyEventuallyBreaksOutOfTheLoop();}". It only gets weird if you use it as a statement itself.
One possible use: Say you have 2 lists of Strings. The lists have the same length, just to make things simple. If an item in list1 is an empty string, you want to use the corresponding item from list2. There are several ways to do this. This is an unconventional one using "or":
Here's one more like what you would expect:
Or, the same thing, as a list comprehension:
Still, it's just an oddity. If you want to force a boolean, you can use bool(a or b). It is a documented oddity. I just hadn't realized that it was there. Like I said, in most cases, it behaves as you would expect it to.
It also makes the implementation pretty easy, actually. For example:
Voila! It all depends on the truthiness of a. In the implementation of the language, b isn't even evaluated unless it needs to be. I guess you could also use that side effect. For example:
One possible use: Say you have 2 lists of Strings. The lists have the same length, just to make things simple. If an item in list1 is an empty string, you want to use the corresponding item from list2. There are several ways to do this. This is an unconventional one using "or":
Code: Select all
[i[0] or i[1] for i in zip(list1, list2)]Code: Select all
result = []
for i in range(len(list1)):
if list1[i] != "":
result.append(list1[i])
else:
result.append(list2[i])Code: Select all
[list1[i] if list1[i] != "" else list2[i] for i in range(len(list1))]It also makes the implementation pretty easy, actually. For example:
Code: Select all
def customAnd(a,b):
return a if not a else b
def customOr(a,b):
return a if a else bCode: Select all
def printMe():
print("Hello")
return 0
def dontPrintMe():
print("I should not print")
return 1
printMe() and dontPrintMe() # This should only print "Hello"BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
woah..
i'm lost.
i have no idea about the whole syntax in your first example, and i don't even know what "zip" does
And the last one is just plain weird. But it makes sense. Took me a while to get it though..
i'm lost.
i have no idea about the whole syntax in your first example, and i don't even know what "zip" does
And the last one is just plain weird. But it makes sense. Took me a while to get it though..

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
zip takes n lists and produces one list. That list contains tuples (which could be considered a special type of list) of n elements - one from each list. It's defined to stop at the end of the shortest list. so zip([1,2,3], [4,5,6]) would produce [(1,4), (2,5), (3,6)]. So in that look for strings example, it goes through each element in the zipped list, and does firstValue or secondValue. If firstValue seems False (i.e. It's the empty string), it uses the second value.
A modified first example (the C/++ code):
In Python, "x if condition else y" is kind of their ternary (?) operator. If the condition is true, it results in x. If not, it results in y.
A modified first example (the C/++ code):
Code: Select all
if(5)
{
cout<<"5 is considered to be \"True\" in C++";
}BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Speaking of Python...
I just learned of a site called Udacity today. It's kind of like an online school, with free online courses. It's not accredited, so you don't get a degree, but the instructors are university professors or professionals in their field. They're mostly programming classes, and the language used, as far as I can see, is Python 2.7 (though the theory learned is valuable regardless of the language). I may or may not have signed up today and enrolled in all of the classes. Simultaneously... Good thing there's no strict deadline!
I just learned of a site called Udacity today. It's kind of like an online school, with free online courses. It's not accredited, so you don't get a degree, but the instructors are university professors or professionals in their field. They're mostly programming classes, and the language used, as far as I can see, is Python 2.7 (though the theory learned is valuable regardless of the language). I may or may not have signed up today and enrolled in all of the classes. Simultaneously... Good thing there's no strict deadline!
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
It's free as in free online classes.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.