[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 34

File: gee.jpg (66KB, 685x709px) Image search: [Google]
gee.jpg
66KB, 685x709px
What are you working on, /g/? Previous Thread: >>58932628
>>
File: 1486857189998.jpg (568KB, 1830x1626px) Image search: [Google]
1486857189998.jpg
568KB, 1830x1626px
>>58940420
Does /g/ ever wish there were more men programming? These upper level classes have almost no guys. It's just another bland wave of girls with bags under their eyes. Pic related.
>>
Anyone here good with embedded systems?
>>
File: 1486861505483.png (971KB, 1276x1432px) Image search: [Google]
1486861505483.png
971KB, 1276x1432px
>>58940468
It's this shit 24/7. And there's someone talking about Bleach behind me during every lecture.
>>
File: programming_shirt1.png (323KB, 869x505px) Image search: [Google]
programming_shirt1.png
323KB, 869x505px
Reminder that all the best programmers dress up as handsome boys.
>>
>>58940513
Sorry, I'm not a faggot so I only dress up as a cute girl.
>>
>>58940622
unreadable code/10 but cute anime
>>
>>58940622
good anime image.
>>58940630
yes
>>
>>58940622
I would fail you if I was your TA
>>
File: quality1.png (438KB, 539x556px) Image search: [Google]
quality1.png
438KB, 539x556px
>>58940601
You're only hurting yourself.

>>58940622
You're a *** programmer.
>>
>>58940622
int rows = 10;
//2lazy2change msb to ensure postive
for (int i = 0; i < rows; i++) {
int val = 1;
for (int j = 1; j < (rows - i); j++) {
cout << " ";
}
for (int k = 0; k <= i; k++) {
cout << " " << val;
val = val * (i - k) / (k + 1);
}
}
>>
First data structures learning about linked lists. Nothing real crazy so far but just programs relating to that
>>
Is it possible to get javascript running on bare metal? I want to make a kernel in it.
>>
>>58940683
Don't let your professors meme you, basic data structures are easy as fuck if explained appropriately. My professor would rant about how hard it is to intimidate everyone all the time, just know recursion well for trees.
>>
File: 1486948537734.gif (126KB, 294x233px) Image search: [Google]
1486948537734.gif
126KB, 294x233px
>>58940690
It is possible, but you'd have to either write a compiler or design new hardware. Also, ew.
>>
>>58940690
In a few years
https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
>>
>>58940683
Linked Lists
Unbalanced Binary Trees
Graphs
Hash Table
>>
>>58940690
kek why would you make a kernal in javascript?
>>
>>58940420

What's a good image compression library for C#?
>>
>>58940690
How would that work?

You transcompile to C?
>>
Python question.

funNumber = 50
FunList = [funNumber]

def funMethod():
global FunList, funNumber
FunList[0] += 1


Why can't I do this? It just creates two different values from when accessed in a list and accessed by it's name. Is it possible to have this variable be consistent when accessed from inside the list and directly from the name?
>>
>>58940706
>but you'd have to either write a compiler
Isn't it bloated as fuck? I can't imagine that being very easy
>design new hardware
Too hard.
>>58940745
When did I say that I wanted to make a "kernal"?
>>58940804
I don't think that can be called running on bare metal.
>>
>>58940420
attempting to decipher wordpress documentation so i can use the newly absorbed wp-rest api with its new syntax
>>
>>58940849
Didn't you ask whether it's possible or not to create a kernel with JS?
>>
>>58940493
>>58940468
>>>/tg/
>>
>>58940863
A kernel? Yes. Not whatever you asked earlier.
I just asked if I can get JS running on bare metal
>>
I'm trying to figure out Java lambda expressions. I'm slowly wrapping my head around them but I don't really understand when to use them or their limitations. Like, can I check if a string is a palindrome just by using lambda expressions in Java? Still trying to figure it out.
>>
>>58940913
>their limitations
lmao
>Like, can I check if a string is a palindrome just by using lambda expressions in Java?
if they are anything like literal lambda expressions from lambda calculus, then yes.
>>
>>58940888
Of fucking course not, you retard.
>>
>>58940926
why? if it's this obvious then you should have no trouble coming up with an answer, right?
>>
>>58940843
Why would you declare a variable is global inside a function if you have already declared it outside of the function?
>>
File: 1466798559489.jpg (2MB, 2000x2610px) Image search: [Google]
1466798559489.jpg
2MB, 2000x2610px
>>58940483
Yes. What's up?
>>
File: uh..jpg (10KB, 258x22px) Image search: [Google]
uh..jpg
10KB, 258x22px
thanks?
>>
>>58940960
Do LED display normally store all the stuff they need to display in the same memory location? Cause I am dealing with an LED with a documentation I can't read.
>>
fp is the future
>>
>>58940690
It's harder to make javascript a statically compiled language. It has dynamic typing, and a bunch of other features that make it difficult to make runtime guarantees of what the machine code will look like. Modern JS engines will compile sections of code and cache them to be run whenever, but depending on how the program is written, the JIT compiler will have to recompile your shit a bunch of times.

I think having a javascript engine that runs on baremetal could work, but to make it reasonably performant, you'd need to do something to keep yourself from writing code that gives the JIT problems.
>>
File: 1466799123560.jpg (68KB, 461x588px) Image search: [Google]
1466799123560.jpg
68KB, 461x588px
>>58940973
Do you mean LED, like individual lights or LED like a screen of them? The most I had to do with LEDs was code review our LED code before I knew enough assembly to understand what I was looking at. I also had to deal with some bugs coming from where LEDs used to be on our boards. Usually it's just a matter of driving them high or low as far as I've seen. This was for the blinky lights on a network switch though, so your use case might be more complex.

In any case, docs and schematics will be your best friends. It's daunting at first, but since what you need to do depends on the parts you're using and the board configuration, that's basically the only way to go about doing it.
>>
File: i'll have two number neps.png (646KB, 1364x768px) Image search: [Google]
i'll have two number neps.png
646KB, 1364x768px
Rate my pascal's triangle implementation!

void pascals_triangle(int iters)
{
iters += 1; /* 1 indexing */
unsigned i, j;
unsigned **arr = (unsigned **) malloc(iters * sizeof(unsigned *));
for (i = 0; i < iters; i++)
arr[i] = (unsigned *) calloc(iters, sizeof(unsigned));
**arr = 1; /* seed */
for (i = 1; i < iters; i++)
{
memcpy(arr[i], arr[i-1], sizeof(unsigned) * iters);
for (j = 1; j < i; j++) /* add */
arr[i][j] = arr[i-1][j-1] + arr[i-1][j];
unsigned k = iters - i; /* pretty print */
while (k--)
printf("%c", ' ');
for (j = 0; j < iters; j++)
printf((!arr[i][j]) ? " " : "%u ", arr[i][j]);
printf("\n");
}
for (i = 0; i < iters; i++)
free(arr[i]);
free(arr);
}
>>
>>58941052
To actually answer your specific question, no, I don't think LEDs normally store the information anywhere. Unless you have a part that intelligently manages them, but thatd be beyond want I can help you with on an anonymous tibetan manuscript appreciation website.
>>
>>58941052
>>58941065
It is one of those LED displays where you can hook up its ports to a microprocessor. The problem is I bought a cheap china one so its documentation is useless to me. Eh I guess I have to slowly figure it out. At worst, I will just drive the ports on and off with a timer.

Thanks anyway.
>>
Does anyone know of a good test database with financial data that is free to use? Google gives me jack shit except the Northwind DB. Which is fine, don't get me wrong, but it would have been nice having something more POS-y or Project Accountancy-ish.

Yeah, I'm writing business applications. We can't all have fun jobs writing frameworks in Java. ;_;
>>
sometimes my program crashes and sometimes it doesn't
>>
>>58941221
valgrind
>>
Learn me a Haskell
Learn you a Haskell
Real good
>>
i feel like i should learn c now that i've become an advanced c++ programmer
>>
>>58941342

Be careful that you don't end up just reinventing vtables and other parts of standard c++ when you step to standard c. It's very easy to do.
>>
>>58940956
Because bare metal requires manual memory management you fucking shithead.
>>
>>58941403
I see, is that why you can run lisp interpreters on bare metal? it's widely known for its manual memory management
>>
>>58941403
how can someone be this retarded?
>>
>>58941403
>requires
Not necessarily, as >>58941410
said, but manual memory management at least implies deterministic behavior. You can have it too with garbage collection, but then the GC will have to be called asynchronously, independent of timing constraints, and that doesn't fare that well with RT systems.
>>
>>58941466
There are ways around it actually. If you pool objects for reuse you won't have to GC them.

Now you might say that this smells like doing most of the memory management manually and you'd be right.

But you can get around garbage collection issues for RussiaToday systems.
>>
>>58941466
The reason that it works for Lisp is because the implementations do the memory management for you. Of course a JS implementation could do the same, but I doubt anyone would be masochistic enough to implement that.
>>
I'm trying to create a jit in C for a toy language. What I'm planning on doing is this [source code] -> parser -> [ast] -> jit -> [native x86_64 opcodes].
I'm basically thinking about mmap'ing a file with the executable bit set, write the opcodes to the file, cast the file pointer to a function pointer and exec that function pointer.
I have three questions:
1) Would this work?
2) Is there a better way?
3) Where might I find a good resource in order to learn and understand x86_64 opcodes? I know next to nothing about assembler.
>>
>>58940420
Learn Go:
https://tour.golang.org





>inb4 YOU MEAN HASKAL
>>
Just converted several simple-and-elegant recursive functions to messier iterative versions.

I realized some non-toy datasets could make my recursion a couple hundred million calls deep which made me nervous.
>>
>>58941791
>a couple hundred million calls deep
that isn't much
>>
File: 1460527731158.png (117KB, 372x351px) Image search: [Google]
1460527731158.png
117KB, 372x351px
>2016
>not writing functional assembly
>>
I'm new to all of this, trying to get started doing some Data Analysis using Python. I'm running macOS and trying to setup a development environment. All I want is something simple; write Python scripts using Vim through the macOS Terminal

Everything was working fine, I was following a video to write my first script, but for some reason Python doesn't seem to be picking up that I've installed packages (scikit-learn).

So I installed Python using Homebrew, but I'm pretty sure it comes default installed on macOS anyway. I couldn't install pip using Homebrew, didn't want to cooperate, so I Googled it and used some 'easy_install' shit through terminal and it worked. Then I had to run 'sudo pip install XYZ' to get it to work and it seems that the packages all got placed in the right directories from what I saw; /Library/Python/2.7/site-packages is where it's located on macOS.

So all the packages I've installed are there, python --version yields that I'm running 2.7.13, so why the fuck when I try to run a script will it spit out an error on the first line "from sklearn import tree" ??

Maybe I'm running the version of Python that I installed using Homebrew and these packages installed to the version of Python that were default loaded into macOS? Is there anyway I could check that or switch it?

All this package management shit is a little confusing to a noobie; not sure where to find some clear info on where a package gets installed, where its config files are placed, etc, etc
>>
>>58941978
>Python
>macOS
Stopped reading right there.
>>
>>58941978
i can help, first answer a question: are you from reddit?
>>
>>58941221
http://clang-analyzer.llvm.org
It's great.

Also the way you put this makes me think you're not running through a debugger with debug symbols. Which is bad.
>>
>>58941978
ONE WORD: THE FORCED INDENTATION OF CODE
>>
>>58941978
Anon I suggest you do this thing where you Google for people with the same issues.
For instance:
http://stackoverflow.com/questions/15274696/importerror-in-importing-from-sklearn-cannot-import-name-check-build
There's no rhyme or reason for why that'd fix the problem but do you really care?
>>
>>58941984
>>58941996
>>58942012
macOS is all I've got to work with at the moment; it's what I've got and it works

As for Python, the University course I'm doing is teaching using a mixture of Python and R; not really my decision. I'm pretty sure Python is used a fair bit in the Data Science industry as well seeing as they are more Statistically & Mathematically trained and programming is seen as more of a tool to get shit done, not really the sole focus
>>58942035
There's not really any clear answer on that page?

Reading around a little more I'm almost certain I've fucked something up with different installs of Python everywhere. Apparently when you install Python using Homebrew (OSX package manager) it comes with Pip. But then me going and using the "easy_install pip" shit installed pip onto the versions of Python outside of Homebrew.

So now it seems I'm running the version of Python (2.7.13) I got from Homebrew but pip is installing packages outside of that version.
>>
>>58942144
why did you reply to me if you didn't even answer my question?
i know how to solve your problem but first I need to know if you're from reddit.
>>
Friendly reminder that video game programming is the highest form of programming.
>>
>>58942144
>Data Science industry
is this thread a "Data science industry" thread or a programming thread? Python isn't programming and shouldn't be even mentioned here.
>>
>>58942170
neg
>>58942179
my bad, forgot how elitest these threads are
>>
>>58942191
yeah, keeping the discussion on topic is so fucking elitist. i can't even
>>
>>58942191
>neg
post a singular anime image and i shall judge it
>>
>>58941791
TCO.
>>
Can someone give me an explanation on lambdas? I'm a retard, so keep it simple.
>>
>>58942241
his shitlang probably doesn't have it.
>>
>>58942254
anonymous functions
>>
could i be causing heap corruptions because i'm using c libraries in a c++ program? my program isn't super complicated and i'm cleaning everything up but for some reason, it crashes sometimes, for no apparent reason, complaining about a heap corruption.
>>
File: 1459587125043.png (188KB, 327x316px) Image search: [Google]
1459587125043.png
188KB, 327x316px
>>58942199
>i can't even
It's this cunt you should be hanging to dry, not me

I asked a question relating to programming, as a beginner; and because I wasn't using Arch 'holdonmumjustfixingmyosi'llsayhitodarrensoon' Linux or writing programs in fucking Binary I didn't get an answer. Seems a little elitest to me. Not to mention 'Data Science' used to just be a more Statistically trained Computer Scientist until the recent big data meme
>>58942207
>2d girls
>>
>>58942284
If you're using them incorrectly, yes.
Run a memcheck (e.g. valgrind) it will detect when anything goes out of bounds.
>>
>>58942288
as i thought, you are indeed from reddit.
you can return to your shitty website now.
>>
>>58942268
Simpler please, I'm a beginner.
>>
>>58942254
This is pretty much it: >>58942268

Imagine you did this:
def add(x, y):
return x + y


This would bind a function to the symbol 'add'.
Lambdas are functions as normal, first-class values, like so:
one = 1 # assigning a symbol an integer value
add = lambda x, y: x + y # assigning a symbol a function value


The 'point' of lambdas in languages that have adopted them (rather than being based on them) is that you can 'use' functions without giving them a name. Hence 'anonymous functions'. Here's an example:

student_tuples = [
('john', 'A', 15),
('jane', 'B', 12),
('dave', 'B', 10),
]
sorted(student_tuples, key=lambda student: student[2]) # sort by age:
# [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
>>
>>58942305
do you know what a function is?
do you know what "anonymous" is?
combining these two concepts gives you an anonymous function aka a function with no name.
>>
>>58942191
>>58942288
Dude, I agree with you, but for God's sake learn to spell 'elitist'. They'll eat you alive.
>>
>>58942257
>>58942241
I'm traversing graphs and do a shitload of branching so it's not really applicable.
>>
>>58942321
No, I use C#, is it the same as a method? Why would you use an anonymous method; are lambdas used for methods only appearing once in code?
>>
File: 1481981198001.jpg (96KB, 752x1062px) Image search: [Google]
1481981198001.jpg
96KB, 752x1062px
>>58942304
Just not a big fan, I've got a few that I've taken a liking to though, rejudge?
>pic
>>58942328
My bad, will correctly spell it next time
>>
>>58942357
looks like an image straight from reddit. you can't fool me.
>>
>>58942373
obviously meant for >>58942361
>>
How do I make a switch menu so that each choice either creates an user file, deletes it, or makes text edits in it, without having to write 200 lines of code in each case?
>>
>>58942373
>>58942381
Seems like you're the new one here

:^)
>>
>>58942429
i didn't claim i wasn't new. i'm from about 2011-2012.
the more important thing is that i'm not from your website.
>>
File: 1465552564492.jpg (155KB, 500x492px) Image search: [Google]
1465552564492.jpg
155KB, 500x492px
>>58942495
You seem pretty adamant on painting me as a leddit user, got something to hide, friend?
>>
>>58940791
Pls answer
>>
>>58942592
>You seem pretty adamant on painting me as a leddit user
which you are. just a quick look at the images you post confirms this beyond any reasonable doubt. there's also your comment about anime, but that's just additional evidence.
even if you don't watch it (which already places you pretty high on the plebbit scale), you can't possibly be a non-redditor if you don't have some anime images with older file names on your hard drive. this is just not possible.
>>
>>58942624
yes sir king of 4chan sir, i will never disrespect you like this again sir

sir, it is my upmost priority that you keep this elitist board the way it SHOULD be

thank you sir
>>
>>58942672
so here we are. you have revealed yourself, pleb.
i would have you shot and thrown into a ditch, but i am ready to pardon you if you can provide me with a non-reddit anime image.
>>
>>58942859
reread my post. i said "non-reddit". or did that website rob you of every last bit of brain power you had?
>>
>>58941723
How about neither?
>>
>>58942880
it seems like you are utterly incapable of following even the simplest instructions. maybe you should write a python """""""program""""""" to help you with that?
is this thing contagious by the way? you should really leave if that's the case. i don't want your kind infecting my fellow countrymen.
>>
>>58942928
>>58942935
what sort of retarded question is this?
>>
>>58941660
It should work and it's the way I would go about it.

https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf

Read section 3.2 so the code you generate doesn't break the caller.

As for encoding instructions, it's described in the Intel software developers guide part 2.

https://software.intel.com/sites/default/files/managed/a4/60/325383-sdm-vol-2abcd.pdf

Although it's complicated and your not going to need all that stuff, just choose the instructions you need, disassemble them and reference that section in the manual that describes encoding.
>>
>>58941253
Outdated trash.
>>
i have a function which requires an int* as paramter

what's the fastest way to pass some garbage in there so it doesn't bother me but, also doesn't try to write something to NULL creating a crash

int a  = 0;
int* p = &a;

i'm currently doing that, i imagine that's actually retarded
>>
File: gnome why.webm (608KB, 1920x1080px) Image search: [Google]
gnome why.webm
608KB, 1920x1080px
i fucking hate gnome with a passion
>>
>>58943273
M A T E
A
T
E
>>
>>58943273
Then why are you using it?
>>
>>58943312
it makes my battery last longer than XFCE
>>
>>58943283
The default window manager in mate is really bad though.
>>
>>58943257
wtf man post function
>>
>>58943257
int a;
f(&a);
>>
>What are you working on, /g/?

node + serverless stuff, it's re-ignited my love of programming.
>>
>>58943430
Nope. Immediately go back to >>>/b/
>>
void foo(){
boo *x = new boo();
delete x;
}


void(){
boo x = boo();
}


i am so confused. i'm supposed to not create things on the heap, correct? so the top thing creates heap corruption?
>>
>>58943273
Works on my machine (tm)
>>
>>58943504
>i'm supposed to not create things on the heap
In general? Why? There are plenty of reasons to create something on the heap

>so the top thing creates heap corruption?
No? Both of those code snippets are fine.
>>
File: why god why.png (21KB, 620x550px) Image search: [Google]
why god why.png
21KB, 620x550px
I think I need to redo my program's debug messages.
>>

class foo
{
private:
std::array<T, ???> myArray;
/*
...
*/
public:
foo(std::array<T, ???> myArray) :
myArray (someOtherArray) {}; //How do I get myArray from someOtherArray?
/*
...
*/
};
>>
>>58943558
Looks good to me
>>
>>58943558
Protip: just print __LINE__ and __FILE__ everywhere. That way, you can copy/paste the same debug message wherever you go.
>>
>>58943504
i should have just googled this . i thought you had to delete fucking everything in c++ and didn't understand the difference between the heap and the stack. no wonder my program crashes because of heap corruption. which is fucking weird because in Qt even though i made the same mistakes.
>>
>>58943504
they're both valid and don't cause "heap corruption", whatever you mean by that

that being said, you can't declare an anonymous function like that (in 2nd snippet)

void(){ /* code */ }


is not valid c/c++
>>
>>58943504
>i'm supposed to not create things on the heap, correct?
Not that you're not supposed to, but in your case, allocating a boo object on the head just to delete it at the end of the same code block is pointless, stack-allocated object will be destroyed automatically at the end of the block.
>>
>>58943504
>foo
good
>boo
bad

https://en.wikipedia.org/wiki/Metasyntactic_variable#English

Reminder to learn something useless every day
>>
>>58943600
*heap
>>
So I have a GUI written in HTML/Javascript and my goal is to link it to several Python scripts that I want to run and send the output (and or errors) back to my GUI. Is this the type of thing you do in Django or what should I use here ?
>>
>>58943643
ajax and php
>>
Is there an assembly -> JavaScript decompiler(?)
>>
>>58943685
what?
>>
>>58943257
It's up to the function author to state whether NULL is a valid input and what is the function behavior in that case.
If passing NULL is invalid, then what you do is perfectly sensible. If you want it a little shorter, in C99, you can use compound literals in such way:
void f(int *a);

int main(void)
{
f(&(int){0});
}

which will pass a pointer to a temporary int variable of value 0.
>>
File: way too long.png (11KB, 437x113px) Image search: [Google]
way too long.png
11KB, 437x113px
I'm having some timing issues, how should I debug them?
>>
>>58942357
Pls respond
>>
>>58943685
no
>>
File: 145604548.jpg (72KB, 446x482px) Image search: [Google]
145604548.jpg
72KB, 446x482px
>>58940420
>finally got libcurl working after days of frustration
>>
>>58942357
Lambdas are often used only once in code yes, but they're also useful if you want to define some behavior that happens after another thing executes. This is called a callback. so if you've got a function (method) like this:

foo(var text, var callback){
print(text);
callback();
}


you can tell it to do something specific at the end of the code by defining some lambda for
callback
. Something like:


bar(){
print("done");
}

foo(var text, var callback){
print(text);
callback();
}

foo("hello world!", bar);
>>
>>58943700
A program which takes assembly as input and produces JavaScript as output.
>>58943752
Would it be hard to make something like that?
>>
>>58943722
Attach to debugger, interrupt during processing, take a look at backtrace, identify slow function, fix, rince, repeat until it's all good.

It may not seem a rigorous method, unlike profiling, but it's quick, practically and statistically gets good results.
>>
>>58943809
>Would it be hard to make something like that?
Extremely
>>
>>58943800
So that's a lambda? Any specific uses?
>>
>>58943876
map f [] = []
map f (x:xs) = f x : map f xs
>>
>>58943876
>>58943922
inc x = x + 1

map inc [4,8,3,5,8,3]
-- = [5,9,4,6,9,4]
>>
>>58943876
Callbacks for higher order functions?

[1, 2, 3, 4, 5].reduce((x, y) => x + y)
>>
>>58943922
>>58943946
>>58943955
I have no idea what any of this syntax is, but I'm new anyway.
Could you write it in simpler code please?
>>
>>58943991
map(list, func) {
list result;
for each x in input list
add func(x) to result
return result
}
>>
File: Screenshot_2017-02-14_16-30-01.png (58KB, 538x331px) Image search: [Google]
Screenshot_2017-02-14_16-30-01.png
58KB, 538x331px
I figured out how to do last.fm scrobbling finally

if you want to help me test you can get the dev version from here:

https://github.com/nukeop/nuclear
>>
>>58943677
what do I need PHP for in my example ? wouldnt something like ajax + django (and possibly tornado since I might need websockets) work as well ?
>>
>>58943991
https://www.codeproject.com/tips/298963/understand-lambda-expressions-in-minutes
n => n % 2 == 1

Quote:
>A lambda expression is an anonymous function and it is mostly used to create delegates in LINQ. Simply put, it's a method without a declaration, i.e., access modifier, return value declaration, and name.

>Convenience. It's a shorthand that allows you to write a method in the same place you are going to use it. Especially useful in places where a method is being used only once, and the method definition is short. It saves you the effort of declaring and writing a separate method to the containing class.

I couldn't have said it better myself if I tried.

https://msdn.microsoft.com/en-us/library/bb397687.aspx
The MSDN example is a little more in-depth, but the idea is the same. If it helps, think about the conditional operator except lambdas are a lot more flexible.
>>
can you beat 5 million primes per second
>>
>>58944137
in a fight?
>>
>>58944130
Okay, so it's basically a method with very little code in it, that's only going to be used once, correct? Only reason lambdas exist is for convenience, same as libraries?
>>
>>58944130
I don't do much functional programming and I haven't ever seen LINQ code before, but I've only been using lambdas when I need to define a callback. What other circumstances do you think they're useful in? Particularly for OOP/procedural programming
>>
>>58944222
Just anytime you don't want to define a top-level function.
>>
>>58944222
using lambdas is FP so pure OOP or procedural wouldn't use them
>>
Any Rustfags around? I'm trying to port this C function
// Format ffmpeg error code to string message
char *format_error(const int code)
{
char *buf = malloc(1024);
av_strerror(code, buf, 1024);
return buf;
}

to Rust and then wrap it as a standard Rust error. What I have so far is
// Converts FFMPEG errors to Rust errors
#[derive(Debug, Clone)]
struct FFError(i32);

impl fmt::Display for FFError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self)
}
}

impl Error for FFError {
fn description(&self) -> &str {
let mut buf: Vec<i8> = repeat(0i8).take(1 << 10).collect();
unsafe {
C::av_strerror(self.0, buf.as_mut_ptr(), 1 << 10);
CString::from_vec_unchecked(transmute::<Vec<i8>, Vec<u8>>(buf))
.to_str()
.unwrap()
}
}

fn cause(&self) -> Option<&Error> {
None
}
}
,
but buf does not outlive the function, so I can't return the string. Any ideas?
>>
literally what is the point of references in C++?
>>
>>58944339
non-nullable pointers
but they fucked it up
>>
https://en.wikipedia.org/wiki/Breeching_(boys)

what the fuck
>>
>>58944196
>Only reason lambdas exist is for convenience, same as libraries?
>comparing functions to libraries
This has to be a joke, right?
>>
>>58944488
it's kind of sad that lambdas aren't taught as a fundamental aspect of programming more important than control structures
>>
>>58944505
i don't think that's necessary. plebs like him can stay in the dark.
>>
>>58944505
guess why anon, because they're really not that important
>>
>>58944196
>Okay, so it's basically a method with very little code in it
Yes.
>that's only going to be used once, correct?
Mostly.
>Only reason lambdas exist is for convenience, same as libraries?
No. http://stackoverflow.com/a/167392/2332318
>>
File: Saviour.jpg (329KB, 561x750px) Image search: [Google]
Saviour.jpg
329KB, 561x750px
>>58944530
the enlightenment is for all people anon
>>
>>58944562
no, only for those who desire it.
>>
Tomorrow I have a OOP exam. How do I learn collections the right way?
>>
>>58944587
collections aren't OOP
>>
>>58944591
>google 'collections'
>first result is "Collections (Java Platform SE 7 )"
>>
>>58944608
>google "OOP"
>google must be OOP
>>
>>58944608
>variables are oop
>functions are oop
sure
>>
Dad is playin around with F#

Semantic whitespace is a horrible HORRIBLE idea.
>>
>>58944681
Semantic whitespace is great for FP 90% of the time. There's 10% of the time when it's absolutely horrible. Optional braces are great.

F# is shit though
>>
>>58944505
How i do switch case:

({
1: function(){
console.log("hello world!");
},
2: function(){
console.log("boobs");
}
})[2]()
>>
>>58944608
drop out if you're this fucking stupid please
>>
>>58944702
>Semantic whitespace is great for FP 90% of the time
How? It doesn't really piss me off but I don't think it's great either.
>>
>>58944591
>nitpicking this hard
>>
>>58944715
It's clutter
>>
>>58944717
Who are you quoting?
>>
>>58944717
How's that nitpicking?
>>
>>58944283
>simple function gets 400 times more complicated
Rust was a mistake.
>>
File: reeee.png (11KB, 716x292px) Image search: [Google]
reeee.png
11KB, 716x292px
Why doesn't this throw a compilation error?
>>
>>58944828
whom are you quoting though?
>>
>>58944840
>reeee
stupid plebbitor. that's not how this is used.
>>/r/ibbit
>>
>>58944840
because it isn't an error?
>>
>>58944840
because it's a runtime error
>>
File: 1469995802346.gif (862KB, 500x700px) Image search: [Google]
1469995802346.gif
862KB, 500x700px
I have a quick question: How can I get a list of friends from facebook? It's for a project I'm working on, and even though I've read the API, I can't see to find a way to get a list of my friends.

I was thinking of simply going to my "friends" page and using something like BeautifulSoup to parse through, but even then, I couldn't find anything...

I'm kind of lost, so I guess what I'm asking is, Is it possible for me to "log on to facebook" through a script?
>>
File: ruby.png (89KB, 959x833px) Image search: [Google]
ruby.png
89KB, 959x833px
Is Ruby used for anything meaningful apart from Rails?

I like the language in principle, but don't want to be railroaded into a single work area -- and it's Rails as far as the eye can see on job boards.

Surely it's used for something else in industry?
>>
>>58944859
>>58944858
Is there a good way of dealing with something like this? I'm not working with anyone else but I'd rather not leave myself open to accidentally using the same key twice. Though I guess it throws the error when you add the item instead of when you try and access it so its not a huge deal, it will throw an error if I try an initialize something that's fucked.

I know I can make a method to check if a key is in the table and then add it if its not. I also know that I can handle the exception.

I guess I'm more just wondering if there is a different type of data structure I should be using. I want good random access in the table. I probably don't need the table to resize at run time.
>>
>>58944892
>Is Ruby used for anything meaningful
No.
>>
>>58944872
>>>/r/abbit
>>
>>58944907
GADTs or dependent types
(C# will never add either)
>>
>>58944872
Are you sure you're using the API correctly?
Also AFAIK they load the friends dynamically via JS so parsing the HTML won't work.
>>
Can i get some advice for how to build this? I have very little experience

I want to make a program to store/recall long strings of characters (and numbers) in a text? file. Then i want a command that substitutes new characters for the originals, like a simple code.

Whats it called to create a text file and store/recall from it? And would string be a good way to store the data, will strings work with the transposition/substitution idea?
>>
>>58944892
>Surely it's used for something else in industry?
Well, it was designed to replace Perl on servers, and it started to do that for a little while, but it was steadily overtaken by Python in that exact use case. Ruby itself is pretty much dying, but some of the languages inspired by it (Elixir, Crystal) are arguably much more useful.
>>
I don't get this at all, can someone explain it to me? how does the compiler know what "term" and "next" means? Are those keywords or something else? How does it know that those are functions and not a and b?


#lang sicp
(define (sum term a next b)
(if (> a b)
0
(+ (term a)
(sum term (next a) next b))))
(define (inc n) (+ n 1))
(define (sum-cubes a b)
(sum cube a inc b))
(define (cube x) (* x x x))
>>
>>58943876
Did you miss this post: >>58942315
>>
>>58944987
I don't know lisp but presumably
>the first identifier (sum) is the function
>the rest are arguments

in haskell this would be

sum term a next b = ...
which is the same as
sum = \term a next b -> ...
sum = \term -> \a -> \next -> \b -> ...
>>
>>58945003
but how does it know that?
>>
>>58945013
>>58945003
So I switched them around and this works:
#lang sicp
(define (sum a term next b)
(if (> a b)
0
(+ (term a)
(sum (next a) term next b))))
(define (inc n) (+ n 1))
(define (sum-cubes a b)
(sum a cube inc b))
(define (cube x) (* x x x))


using drracket.
>>
>>58945013
what do you mean how does it know?
the first is the function name (sum) and the rest are arguments
>>
>>58944872
def get_friend_list():
return []
>>
>>58945046
>>58945038
Then how does it interpret
(next a)

at the sixth line while simultaneously using next as the third argument?
>>
>>58944892
Vagrant. Chef. Puppet.

JRuby can make JVM dev less painful, but Clojure is a more popular and faster option there.
>>
>>58945067
the "next" parameter is also a function, it's a function parameter
in
sum (next a) term next b

sum(next(a), term, next, b)
>>
>>58945081
>Vagrant. Chef. Puppet.
Those are memes and don't actually do things.
>>
File: 1467053068508.png (34KB, 657x657px) Image search: [Google]
1467053068508.png
34KB, 657x657px
>tfw thread is comprised of people doing real maths and shit and you're making a high level windows forms application
>>
>>58944987
I find it surprisingly annoying that so much of the LISP source I see reimplements foldr over and over.

I'm aware that it's often available as a library function, but still I see explicit recursion everywhere.
>>
>>58945090
Yeah, all that infrastructure just manages itself and/or is managed by heroic sysadmins and their shell scripts.
>>
>>58945067
The function is a value like an integer or any other.
>>
>>58945122
If there aren't heroic sysadmins around to do things, then nothing gets done. Automation only goes so far.
>>
>>58945088
So this is interpreted as
(sum (inc a) cube inc b)


how does this work, then?

>>58945128
Without any arguments? Or is it ignored if it doesn't have any?
>>
>>58945095
>frog poster

serves you right
>>
>>58945172
(next a)

Is calling a function with one argument.
It's equivalent to
next(a)
, for example.
>>
>>58945138
No, if your sysadmins have to be heroic, then nothing gets done. A proper 100 server+ system is fully automated up to and including disaster recovery. This is where shell scripts, Fabric, Ansible, etc. are no longer enough and you need tools like Chef.
>>
>>58945187

actually dm now when I see the state of this >>58944872
>>
>>58945188
Should point out that the second snippet is in a different language, if it wasn't clear.
>>
>>58945172
When you are defining a function, it will make the first identifier the function name and the rest the arguments. Everywhere else, it is application.

define (next a) e -> next(a) { return e; }
next a -> next(a)
sum (n a) b c d -> sum((n a), b, c, d)
>>
>>58944976
Crystal looks very promising, even if it is still in alpha. Going to keep an eye on it
>>
>>58945192
Chef doesn't actually do anything. It's just calling shell scripts that do all the real work.
>>
>>58945188
>>58945203
I get that, but how does it work without an argument? I know your example has one.

>>58945206
but b and c are functions here without arguments.
>>
>>58945232
The only difference between a function and a non function is that a function can be called.

If it has no arguments, it isn't a function.

sum (n a) b c d
(((sum (n a)) b) c) d
>>
>>58945243
So is it ignored, then?
>>
>>58945232
The function is just a value, like '1' or any other: you can assign it to a symbol.

Look at this post for more information: >>58942315
>>
Who ever thought the way strtok works is reasonable?

It's such an obviously awful design (arguably the worst in the C standard library) that it boggles the mind why/how it was ever included. Even without considering thread safety (which could have been neglected in the old days) it's hopelessly flawed.
>>
>>58945253
What is ignored?

(define (sum term a next b))
at this point, sum is a function
you don't know that anything else is a function

(sum term (next a) next b)
at this point you call sum, but you also call next so you know next is a function

lisp is dynamically typed
>>
>>58945218
By that logic shell scripts don't actually do anything because it is the coreutils that do the real work.
>>
>>58945276
Coreutils don't actually do anything, it is the CPU that does the real work.
>>
Need to plot some shit, simple 2d xy stuff with maybe a legend, is el pitone the way to go?
Almost never touched it, i would like some simple shit where i just copy paste some code, modify it a bit and i get a picture out of it; what's the go to library?
>>
Is functional programming back in this thread or is it just dead? It used to have it's own thread, i think.
>>
>>58945289
Functional programming was never alive.
>>
>>58945289
It was just one guy making the threads. I made fun of him until he ragequit.
>>
>>58945289
It had its own thread over Christmas (when noone was working), but more of /g/ is converting to the Truth
>>
>>58945255
Hwo does a function without any implicit declarations work without any input?

It doesn't have parentheses, it isn't a function.

>>58945271
>What is ignored?
functions without arguments, are they ignored?

>>58945271
>(define (sum term a next b))
>at this point, sum is a function
>you don't know that anything else is a function
>(sum term (next a) next b)
>at this point you call sum, but you also call next so you know next is a function

yes, that's the next within the parentheses. What about the next without them?
>>
i need to ship some images with my program, how would i do that? i can't just put them in a folder, can i? can i put them in a dll somehow?
>>
>>58945315
parentheses:
sum(term, next(a), next, b)

no parentheses:
sum(term, next, a, next, b)
>>
>>58945256
>thread safety
You have to keep in mind that processes were Unix's primary concurrency tool, and most of the early tooling was built with the expectation that creating new processes was a fairly lightweight operation. Shared-memory threads within the same process didn't appear until much later, and that was due to differing costs on different architectures for switching between concurrent processes.
>>
>android app for phones and tablets.
>everything layout/
>create layout-large/
>some views can re-used
>don't want two copies of same view in two different folders

wat do?
>>
>>58945333
Are you stating that both your examples are equal?
>>
>>58945315
>It doesn't have parentheses, it isn't a function.
I think you should probably become more familiar with the subject before making assertions like that.

Some Python:
x = 1 # assign the integer value '1' to the symbol 'x'
f = lambda i: i + 1 # assign a function value to the symbol 'f'
print(f(2)) # prints '3'
def addOne(num): # assign a function value to the symbol 'addOne'
return num + 1
add1 = addOne # assign the function value that is bound to 'addOne' to the symbol 'add1'
print(add1(2)) # prints '3'
add1 = None # assign the 'None' value to the symbol 'add1'
print(add1(2)) # error
>>
>>58945361
I'm using LISP, though. And I understand your example, but don't see how it correlates to my problem.
>>
Can anyone help me write a driver in Racket?
>>
>>58945361
>Python
stopped reading right there.
>>
>>58945360
No
I'm showing you the C style comparison

sum term (next a) next b
sum(term, next(a), next, b)
calls sum with 4 arguments

term
next(a)
next
b

sum term next a next b
sum(term, next, a, next, b)
calls sum with 5 arguments

term
next
a
next
b


>>58945361
>Python
Trash language, what it does is probably wrong.
>>
>>58945340
Like I said, thread safety is not the only thing awful about it, the worst thing is state between calls. If your code using strtok calls any functions while it is parsing with strtok, none of those called functions can use strtok() without screwing your function up. Similarly, no library function can use strtok without documenting that it does because any caller that is also using strtok will be screwed up.

For any non-trivial use strtok can be absolutely deleterious.
>>
>>58945382
No one can help you if you're writing a driver in Racket.
>>
>>58945393
I understand that, but I don't get how the compiler knows what is a fucntion and what isn't, and how it interprets functions without any inputs.

>>58944987
>>
>>58945407
(define (sum a b c d e) ...
sum is a function
everything else is a parameter to sum/a regular value

(later on)


(c e)
c is still a value and a parameter to sum, but it is itself a function
lisp is dynamically typed so it's not like C has to have function type or whatever
>>
>>58945394
Right, you want strtok to be fully reentrant. But the actual solution to this problem is to only use it in one place per process, and have those processes communicate with each other instead of nesting strtok invocations.
>>
>>58945384
Luckily you're not my target audience. I was going for a simple language.

>>58945377
It demonstrates that you don't need parentheses around a symbol for it to be bound to a function.

In Scheme:
(define x 1) ; assign the integer value '1' to the symbol 'x'

(define f (lambda (i) (+ 1 i))) ; assign a function value to the symbol 'f'

(write (f 2)) ; prints '3'

(define (addOne num) (+ 1 num)) ; assign a function value to the symbol 'addOne'

(set! add1 addOne) ; assign the function value that is bound to 'addOne' to the symbol 'add1'

(write (add1 2)) ; prints '3'

(set! add1 #F) ; assign the '#F' value to the symbol 'add1'

(write (add1 2)) ; error
>>
>>58945393
See >>58945433
>>
>>58945407
>I understand that, but I don't get how the compiler knows what is a fucntion and what isn't, and how it interprets functions without any inputs.
It doesn't know that ahead of time. If you call something as a function, it will check at the last minute to make sure it really is a function. If not, it signals an error and your program aborts.
>>
>>58945445
yes but that's because you've got a lambda on the right hand side
>>
>>58945430
And you don't see how that's an absolutely awful design?

It's a function you literally cannot put in a library because if you do it might break if someone using the library will also want to use it in some other part of his own code.
>>
>>58945433
>I was going for a simple language.
why the hell did you pick python then?
>>
>>58945479
Because he wants things spelled out simply.

>>58945475
I need more. What part are you replying to?
>>
>>58943273
back to windows
>>
>>58945477
Early Unix didn't use libraries so much. It used processes. I don't see what part of this is hard to understand.
>>
>>58945449
>>58945433
>>58945423
I think I get it now.

Now, this will give me an error, right?
(define (square x) (* x x))
(define (cube x) (* x x x))
(define (sum a term next b )
(if (> a b)
0
(+ (term a)
(sum (next a) term next b))))
(define (inc n) (+ n 1))
(define (test-fn a b)
(sum square a b cube))
>>
>>58945504
at runtime, yes

(because Lisp is dynamically typed)
>>
File: daweawdwae.jpg (13KB, 423x173px) Image search: [Google]
daweawdwae.jpg
13KB, 423x173px
not all char* are created equal
>>
>>58945523
just starting out with lisp too. is pretty much everything aside from undefined references determined at runtime?
>>
>>58945567
i guess

you can always switch to Haskell if you want types, but Haskell doesn't have lisp macros
>>
>>58945567
As a general rule, everything in LISP happens at runtime except for macro expansion.

Of course, you can compile the language if you like, at which point more checks might be done.

>>58945588
Template Haskell is horrifying.
>>
>>58945598
>Template Haskell is horrifying.
not really, but i would like something better
>>
>>58945588
I already know it.
>but Haskell doesn't have lisp macros
that's one of my reasons for learning lisp.
>>58945598
i was just asking since i haven't dealt with a dynamically typed language before.
>>
>>58945660
post an anime image as a sign of your gratitude
>>
>>58945650
>i was just asking since i haven't dealt with a dynamically typed language before.
That's alright, dude. I didn't insult you or anything.
>>
>>58944892
rpg maker xp had a scripting layer written in ruby so it has that going for it
>>
>>58945665
Faggot
>>
File: 1460034782171.png (29KB, 300x300px) Image search: [Google]
1460034782171.png
29KB, 300x300px
>>58945733
>>
File: 1352550303515.jpg (49KB, 413x357px) Image search: [Google]
1352550303515.jpg
49KB, 413x357px
>>58945665
>>
File: Barnacles.gif (2MB, 360x264px) Image search: [Google]
Barnacles.gif
2MB, 360x264px
>>58944938
>Are you sure you're using the API correctly?
Possibly? I mean, I've been using the "graph explorer" tool they give you to test out some "access tokens", but it ends up giving me only a very small number of the friends I actually have.

I was reading on SO on how this is intentional and how you can only get friends that have your application installed (which is understandable, but still dumb...
Source: http://stackoverflow.com/questions/23507885/retrieve-full-list-of-friends-using-facebook-api/23510232#23510232
)

Do I really need to submit my app idea to FB so I can retrieve my "taggable friends"? This honestly feels like jumping a bunch of hurdles when I don't need to.

> they load the friends dynamically via JS
Gosh dang it.

>>58945048
Okay ouch
>>
>>58944283
The way C handles errors is different than Rust so that it doesn't easily map between each other.
description
requires to return a string slice, so FFError must either own something that can return a
&str
or it must return a
&'static str
, a string literal.

Something like this might work:

use std::string::FromUtf8Error;

fn format_error(code: i32) -> Result<FFError, FromUtf8Error> {
let mut buf: Vec<i8> = vec![0; 1 << 10];
let err;
unsafe {
C::av_strerror(code, buf.as_mut_ptr(), 1 << 10);
err = String::from_utf8(transmute::<Vec<i8>, Vec<u8>>(buf))?;
}

FFError(err)
}

// Converts FFMPEG errors to Rust errors
#[derive(Debug, Clone)]
struct FFError(String);

impl fmt::Display for FFError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}

impl Error for FFError {
fn description(&self) -> &str {
self.0.as_str()
}
}


It's better to convert as soon as possible to native Rust strings and have FFError contain the string.
>>
>>58944283
>>58946061
Also note,
fn cause()
has a default implementation, there's no need to reimplement it if you don't need it
>>
>>58946061
FFError(err)
should have been
Ok(FFError(err))
>>
>>58946061
I just realized: it should better be
let mut buf: Vec<i8> = Vec::with_capacity(1 << 10);
instead of
let mut buf: Vec<i8> = vec![0; 1 << 10];
, otherwise buf will contain zeroes after the error message.
>>
What's the best C/C++ arbitrary precision arithmetic library for use with currency/money? Something equivalent to Python's decimal.
>>
>>58945609
Shen?
>>
>>58946339
who?
>>
>>58940843
you can do this, you don't even need to declare the variables global in the function because they're already in global scope and you aren't messing with their reference
>>
>>58946124
>not programming assembler friendly
>>
>>58946355
?
>>
>>58946344
http://www.shenlanguage.org/learn-shen/tutorials/shen_in_15mins.html
>>
>>58946370
Looks shit
>>
>>58945095
>and you're making a high level windows forms application

keyword there is making

the dipshits in this thread debating functional programming paradigms and language questions will toy around with a concept or do a few functions that never actually get realized into something tangible, just by actually producing something you're infinitely more productive than anyone in this thread
>>
Is there a standard markup language to document JSON APIs?
Like, a machine-readable markup that you can generate human-readable HTML documentation out of?
>>
Hi guys, simple question here. Look at this program.

#include <stdio.h>

int main (void)
{
int numbers[10] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int i, j;

for ( j = 0; j < 10; ++j )
for ( i = 0; i < j; ++i )
numbers[j] += numbers[i];

for ( j = 0; j < 10; ++j )
printf ("%i ", numbers[j]);

printf ("\n");

return 0;
}


Output:
1 1 2 4 8 16 32 64 128 256


I am aware of how it works. It's adding previous numbers to get a new one(Like looking for the Fibonacci number). My only problem is that I can't follow the logic when I am doing it on paper. I get a different number as the output when I run it in paper. (I am guessing the double for loop is throwing me off). Thanks in advance.
>>
>>58943369
that's a very shitty reason.
If you want long battery, maybe switch to something more lightweight, like i3
>>
>>58945271
Note that while Common Lisp is dynamically typed, it does offer type declarations. For example, I can do:
(defun five-vector (v)
(declare (type (vector integer 5) v))
v)
>>
>>58946564
does it have GADTs indexed with heterogeneous kind equalities?
>>
Today I learned that Rust is fucking terrible at interfacing with non-trivial C libraries. The sane thing to do is to write a small wrapper in C and only call that from Rust, at which point you might as well use some other language.
>>
>>58946580
Get back to me when you figure out how GADTs work in a dynamic language.
>>
>>58946638
are you telling me it has type declarations but not type checking?
>>
guys how do i create my function to count down in python?

this is what i have so far :

def countdown(N,n=0):
print(n)
if n < N:
countdown(N,n - 1)

but it wont stop counting down when i run it
>>
This thing won't budge.
reverse' xs = foldl (\acc x -> x : acc) xs []
>>
>>58946647
Who said that?
>>
File: game.png (32KB, 1022x969px) Image search: [Google]
game.png
32KB, 1022x969px
I'm making a puzzle/arcade game. Find the color that's off, and the square will split. RIdiculously simple, quite addicting.

Anyone have any suggestions on how to generate colors with a certain contrast to another color? I'm using a numeric minimization algorithm right now, but it's not very reliable.

I have a metric to calculate the contrasts between two colors.
>>
>>58946685
[] and xs in the wrong order
>>
>>58946684
Use a loop instead of recursion
>>
>>58940468
they're traps
>>
>>58946684
def countdown(n):
print(n)

if n > 1:
countdown(n - 1)
>>
>>58946737
Fuck, I'm retarded. Thanks anon.
>>
>>58946773
yw
worst dragon
>>
>>58946532
The way I would think about it is like this:

The first for-loop is visiting each position in your 'numbers' array, and then for every one of those positions, the second for-loop sums up everything that the whole array contains at that moment and puts it at the position j is pointing to.

When j == 0, the sum is 1 (since you already put a 1 there) so position 0 will have a 1. When j == 1, the sum of the array is still 1, so that position will contain a 1. When j == 2, the sum of the array is now 2, so that position will have a 2. When j == 3, the sum of the array is 1 + 1 + 2 == 4, so that position will be 4.. etc.
>>
>>58946791
actually, it only sums up to the current position my bad, doesnt change the logic since you fill it with zeros anyway.
>>
>>58946782
better?
>>
>>58946745
>>58946751
thanks guys!

i just started learning python last friday in class so im having a bit of trouble wrapping my head around it. I feel like its almost clicking together though if that makes any sense
>>
>>58946737
so they are "reverse''d"? lmao xD
>>
>>58946834
ebin meme
>>
Still working on the nested ctf that I have been all week. I am on layer 6 now which is pretty nice. What would this line of code do if eax is a 32 bit int?

mov     dl, byte ptr [eax]
xor dl, 0x12
mov byte ptr [eax], dl


>>58946684
def countdown(n):
for x in range(n, 0, -1):
print(x)
>>
hi guys freshman csci major here, i have an assignment to divide two ints in C, can anyone help me out?
>>
New to SQL, why can't I add foreign keys through alter table? I already checked the data type is the same, I don't know if I've maybe missed something?

CREATE TABLE Movimiento
(
IDMovimiento varchar(50),
IDCliente varchar(50),
IDPelicula varchar(50),
Fechaderenta varchar(50),
Fechadedevolución varchar(30),
Fechadeventa varchar(30),
Folio varchar(50),
Precio Double
);
CREATE TABLE Pelicula
(
IDPelicula varchar(50),
Titulo varchar(50),
Autor varchar(30),
Rating varchar(30),
Existencias Bool,
Precio Double
);
ALTER TABLE Pelicula
ADD PRIMARY KEY (IDPelicula);
CREATE TABLE Cliente
(
IDCliente varchar(50),
Nombre varchar(50),
Dirección varchar(50),
Teléfono LONG,
Clave varchar(10),
RFC varchar(30)
);
ALTER TABLE Cliente
ADD PRIMARY KEY (IDCliente);
ALTER TABLE Movimiento
ADD PRIMARY KEY (IDMovimiento);
ALTER TABLE Movimiento
ADD FOREIGN KEY (IDPelicula) REFERENCES IDPelicula(Pelicula);
ALTER TABLE Movimiento
ADD FOREIGN KEY (IDCliente) REFERENCES IDCliente(Cliente);


Dunno how to post code, I'll delete this post if I fail.
>>
>>58946807
>>58946791
Thanks anon, now I understand how it works.
>>
>>58946890
You can't divide ints in C.
>>
File: 13111912317362.jpg (104KB, 700x745px) Image search: [Google]
13111912317362.jpg
104KB, 700x745px
>>58946890
>>
>>58946890
Sure thing bud!

int x = 10;
int y = 111;
int z = y % x
cout << z;
>>
>>58940420
Webpage for college, with CSS in the head of the HTML file.
>>
>>58946890
int x = 99;
int y = 10;
cout << (x % y);
>>
>>58940843
Bad grammar to name a variable beginning with a capital letter, btw.

funNumber = 50
funList = [funNumber]

def funMethod():
funList[0] += 1
>>
NEW THREAD!

>>58947004
>>
>>58946751
ok so when i tried to make it count up it wouldnt stop and kept adding one
Thread posts: 320
Thread images: 34


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.