[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ Daily Programming Thread, Super Loo Edition
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 36
File: poo-in-loo.jpg (54 KB, 628x314) Image search: [Google]
poo-in-loo.jpg
54 KB, 628x314
Previous thread >>53855925
What Loo do you Poo Pajeet?
>>
>>53871881
My current code is:
http://pastebin.com/5EMKcACj
The error messages say that theInstance is undefined. I tried writing:
HeartHandler* theInstance = nullptr;
on line #18, but it doesn't like me doing that. I also tried writing:
HeartHandler* HeartHandler::theInstance = nullptr;
right after the class declaration, but that gave me all sorts of errors.

>>53871985
You're creating a new one each time in that code.
>>
>>53872166
>You're creating a new one each time in that code.
no you're not. that's what the static keyword is for
>>
File: forwhatpurpose.png (83 KB, 531x410) Image search: [Google]
forwhatpurpose.png
83 KB, 531x410
ITT: Reasons to be worried when you start reading a programming book
>>
>>53872166
see>>53872203
stupid cuck
>>
>>53872228

Note to self: write programming manual, insert pony memes.
>>
At what point while learning programming do things start to branch out from CLI programs to programs that, I don't know, mesh with the outside "world"? So far I feel like I've been in this bubble where the extent of my efforts is bound at a console(or GUI) running after compiling something within the IDE. At what level do things feel more real and useful?
>>
>>53872405
Start with something that you and your friends can use, like a web crawler that finds all the trap threads on /b/ or something.
>>
>>53872405
the only way to break out is to challenge yourself.

I once showed my roguelike I was making using ncurses to a friend. His first response was "Cool but where's the graphics". Of course I didn't know how to do it, but I learned.

find something that you wish existed and then make it. the project should be small at first and you'll work your way up
>>
>>53872373
>not ayylmao, cuck, and meme variables
bruh...
>>
>>53872405
Day 1. That was a stupid thing to do, but much more fun.
>>
>>53872457
what
>>
>>53872228
Was reading a programming book where it started using anime names in their examples.
>>
>>53872405
I'm not sure what you mean by "real world." Are you trying to interact with the internet, with the CPU, with robotics? Do you want to be able to deploy your software to users?
>>
>>53872405
Your "bubble" is only in your imagination. If you feel you're competent enough, start looking into graphics libraries or other stuff
>>
>>53872405
What do you consider "real world"? A web application or mobile app?
>>
https://hackage.haskell.org/package/register-machine-typelevel-0.1.0.0
what is your excuse for not using a language with type-level virtual machines?
>>
>>53872405
You could make an IRCbot or something. I remember when I used IRC there was a bot that for one of its features gave webpage information when a link was posted.

>>53872228
ITT: Barneyfag
>>
>>53872405
first, this >>53872479
Second, if buy a raspberry pi if you want to get "out and about". Use an arduino to design and program your own drone or tracked RC vehicle.

Personally, I use programming to analyse financial markets (personal projects) and in work I use programming to analyse huge databases for the production of aircraft (of all things). It's undeniably useful.
>>
>>53872473
I skipped the CLI part and fucked around with some OSS, until things started making sense. Not very efficient, but fun.
>>
File: Seymour_Barf.jpg (18 KB, 200x283) Image search: [Google]
Seymour_Barf.jpg
18 KB, 200x283
>>53872510
>Haskell
>>
>>53872535
>not Haskell
>>
>>53872510
I like state and I hate intricate static typing.
>>
>>53872510
I value what little sanity I have left.
>>
>>53872228
>list called myFavoritePonies
>no Rarity
Yeah I'm fucking worried
>>
>>53872431
>>53872440
>>53872490
>>53872479
>>53872531
So, if I understand this correctly, what you're all basically saying is "identify something you want. Then go find the resources and challenge yourself to make it." Right?

Cause right now I'm a student and this algorithm and data structure stuff is great, learning all different programming languages and making cool programs with them for classes, but none of it feels like it's really doing anything.

Is that what you guys are basically saying?
>>
>>53872553
Haskell has state. You can even have global mutable state with IORef
>>
>>53872510

If I wanted to have a turing machine at the type level, I'd use C++.

>>53872566

Obviously this C# developer has no class.
>>
>>53872546
I'd rather use Lisp (which despite the rumors, it doesn't seem to be that difficult to grasp)

>>53872566
He likes that yellow slut over Rarity, what a faggot.

>>53872584
Pretty much. If you don't challenge yourself, you'll never learn anything. Learn something new every day.
>>
>>53872228
all can be accomplished in 3 lines with Basil.
>>
>>53872584
yeah, exactly. it's analogous to any other craft, for example wood working. you don't need to learn all the techniques and joints to make a table, but you need to learn some.

eventually, when you've made enough tables, chairs, shelves, etc, you'll be able to just think of an idea and start doing it.

exactly the same for programming. just pick something you don't know how to do and learn how to do it.
>>
>>53872610
It's more like a combination of the fact that I'm a student about to graduate college, not really a programmer, but still enjoy the programming I do know and want to find a cool way to emphasize that on a resume (I know that sounds pretty bad).
>>
>>53872553
>I like state
absolutely disgusting
>>
>>53872228
>using UnityEngine;
fucking cancer
>>
>>53872642
>haskell has no state
>>
>>53872642
fucking idiot

everything has state

a stateless program is fucking useless
>>
>>53872637
I need to add because that came out wrong. I love the feeling I get when I've created a program and it does what I want and I'm proud of it. I want to build on that and learn and get better.

But I want to do that in the most useful way possible because I don't have time to sit around creating mini-programs with textbooks. I need to apply my knowledge and start having something to show for it. That's what I meant.

>>53872630
This seems like the best idea. Find something I'm excited about, an idea for a project. Then implement it and get help where I need it.
>>
>>53872585
I supposed I should have specified mutable state. And from my understanding only the IO bits have mutable state and its obtuse and horrible.

>>53872642
Emulating the effects of mutable state by passing state copies around in function calls is like emulating the effects of recursion using Y combinators and no globals. It's fucking stupid.
>>
>>53872660
Exactly, Haskell is useless.
https://www.youtube.com/watch?v=iSmkqocn0oQ
>>
>>53872660
State is a necessary evil. You shouldnt enjoy using it.
>>
>>53872680
If you want parallelization at all, you need to make all your data structures immutable anyways and then you have the same effect.
>>
I am signed up for this program in my area, it's like a free boot camp: http://www.codelouisville.org/candidates/

This fall's program is website development. For the back 12 weeks, I get to choose between either .NET development or PHP development.

I don't really care to do web development but I'm already enrolled and may as well learn a skill. Which one should I choose?
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>53872743
fuck off retard it's not "evil" it just is what it is
>>
>>53872788
>>53872743
>>53872724
Is this what you fags do on /g/ all day? Jesus Christ /sci/ wasn't kidding
>>
>>53872818
Nah, it just people making memes
>>
>>53872818
Why else come here, if not to shitpost?
>>
>>53872774

If you don't want to do web development, go with .NET. It has plenty of uses outside of web development, while PHP is an absolute shit pile.

Also, while code boot camps are mostly scams, if it is free, you may as well take it as an opportunity to network.
>>
>>53872767
I'm unsure of how parallelization works without mutation. How do you communicate data to another program/process without modifying state?
>>
>>53872857
the first step is realizing that messages don't need to be modified.
>>
>>53872865
The application of a message to a separate process is still modification.
>>
>>53872856
I used to code in high school as a hobby but didn't pursue it as a career. Ten years later I'm stuck in an I.T. job I hate and wish I were coding, but forgot basically everything. This is just a way to relearn everything.

They eventually offer app development courses, which is what interests me the most, but it might be like 14 months before that's available again, so may as well learn some HTML
>>
>>53872503
Real world as in a program that does more than display and receive text in a command line, and reading from a text file. Something that gets more involved be it the computer or the internet or other programs. Also something that can be ran as software and not having to be compiled every time but I'm sure that's easy enough
>>
>>53872818
/sci/ is seriously one of the worst boards here, wish it wasn't true.

>50% homework questions
>50% faggots posting dumb "puzzle" questions that result in shitstorms
>50% redpill me on X equivalents
>100% slow
really no point in going there.
>>
>>53872857
What do you mean? Typically, a thread has an immutable pointer to a dispatch data structure. Its own state should be immutable to protect it from being modified by other threads.
>>
>>53872767
no you don't, you just need to synchronize/atomicize access, fucking buffoon
>>
>>53872922
What I mean is the "purest" I have ever thought to reduce a system of processes to is with mailboxes.

That is if one thread needed to send data to another, it would do something like (mail! another-thread message).

The mailbox of the other thread necessarily has to be mutated.
>>
>>53872885
this

you're just modelling it in a fucktarded way because you're retarded, you're just pretending that it isn't mutation of state
>>
>>53872951
That destroys performance.
>>
>>53872973
and creating immutable data structures doesn't? what the fuck you fucking retard. and no it doesn't destroy performance for fuck's sake can you please kill yourself or just shut up about things you have no idea about. and you still need to guarantee visibility of your immutable dater strugers
>>
File: 23523523243.jpg (72 KB, 408x408) Image search: [Google]
23523523243.jpg
72 KB, 408x408
>everyone knows about states and their relation to concurrency except for me
can I just use std::thread and std::async and live in abstracted bliss or should I do some reading on this stuff?

read ? got_any_good_books : back_to_work;
>>
>>53873022
>can I just use std::thread and std::async and live in abstracted bliss
yes and don't listen to the hasklel retards they're fucked in the head
>>
>>53872967
>>53872922
Actually I'd really like you to show me a really simple example of pure functional IPC.
>>
>>53873034
they won't because they just have some vague meme idea that immutable data structures solve everything
>>
>>53873034
That is impossible. Purity can only be achieved on the function or function chain level. Anything that these functions return to at the end is stateful and not pure.
>>
>>53873077
I'm more interested in haskellchan's response though.
>you need to make all your data structures immutable
If it's pure then it's pure.
>>
>>53873034
>>53873077
This. You're overhearing me. I'm not saying you need to have 100% immutability. But you can minimize it to a very very small section of code.
>>
New CE student, recently installed Debian on a tiny Acer netbook I found in my attic. Working with vim on projects because this thing is not very powerful. Is there any way to minimize functions (in c++) in vim like you can in notepad++? We use notepad++ in class and that is such a useful feature for when projects get bulky or hard to read.
>>
Is there a way to make something appear to compare to two different values without writing the first variable twice? Something like
a != (8 & 5)
being expanded to
a != 8 && a != 5
, for golfing reasons.
>>
I wish Haskelfags could admit their language is a dirty slut, like the rest, and stop with this MUH PURITY meme.
>>
>>53873167
use folds
>>
>>53873128
it's just common sense to minimize the "critical section" regardless of paradigm
>>
>>53873171
need two statements for two comparisons.

8 && 5 is just always equivalent to false.

people also get tripped up on stuff like 2 < x < 5, thats just mathematical short hand, you have to write x > 2 && x < 5
>>
>>53873205
Yes.
>>
>>53872922
>Its own state should be immutable to protect it from being modified by other threads.
No, its own state should be mutable. It can only be modified by other threads if they have access to it, which they don't.

"Muh immutable" just forces more work onto a system of global state called the GC.
>>
>>53873192
but functional purity in Haskell isn't a meme. it actually exists
>>
File: 1428433220648.jpg (96 KB, 531x471) Image search: [Google]
1428433220648.jpg
96 KB, 531x471
>>53872743
>state is a necessary evil
>functional programming is relevant I promise
>>
>>53873235
Sure, it'll probably need to do the comparison for both numbers in the non short-circuit path, but is there some well established idiom that makes that invisible in the code and is kinda short? I've been playing some puzzles at Codingame and would like some more tools for making code golfing easier.
>>
    
int sumArray(int aArray[], int length) {
int x = 0;

for (int i = 0; i<length; i++)
x += aArray[i];
return x;
}


I need to do three things with this function. I need to return the max int in the array, i need to display how many negative numbers are in the array and i need to display true or false based on the presence of a negative integer.

I am a little confused with how a function is called and how the array is checked.
>>
>>53873272
sounds like this is a cpu time vs memory argument. besides, even if Haskell as a language is immutable, that doesnt mean it needs to be compiled to machine code where everything is immutable.
>>
>>53873308
Yes. Individual functions can be pure, but a language as a whole can not. A pure language can have nothing more than no ops.
>>
>>53873359
There is no definition for "a pure language". Pure functions are called "pure functions" because they are pure in the mathematical sense. there is no equivalent to an entire program in math. so in Haskell, even though all functions are pure your code can still perform side effects, just not through the functions
>>
>>53873324
write a macro?

i don't really know how code golf works and don't really want to but what you're trying to do sounds a little dumb unless you have to do that operation a bunch of times for some reason in your code.
>>
>>53872476
Link?
>>
>>53873331
Not related, but if someone did
int sumArray(int aArray[], int length) {
int x = 0;
for (int i = 0; i < length; x += aArray[i++]);
return x;
}


How would you feel about the code?
>>
>>53873392
For example, counting vowels in a word. That would be comparing the letter to a, e, i, o and u. Without pattern matching, that comparison would be pretty much long.
>>
>>53873324
no, except for (a ^ 5) * (a ^ 8) but then you're still writing a twice
>>
>>53872405
Sockets?
>>
>>53873552
Tell me more friend
>>
>>53873578
https://en.wikipedia.org/wiki/Network_socket
>>
>>53873586
thank you my love
>>
>>53873444
Fine code. Needs a comment to satisfy most project managers, but it makes sense.
>>
>>53873308
Still waiting for that pure functional IPC in Haskell. Or maybe it doesn't support IPC at all, in which case that's just awful.

>>53873392
He's trying to write the shortest program possible for dick-measuring purposes, so macros count against you.

The real answer is to switch to a language more suitable for code golf like perl.
>>
>>53873444
disgust
>>
>>53873617
how are any current IPC solutions not purely functional?
>>
>>53873641
Show me an example of pure functional IPC.
>>
>>53873492
>pattern matching
wot

i think a switch(case) would solve that vowel problem pretty easily. i have no idea what you're talking about anymore.
>>
>>53872049
i want to learn game development, can anyone show me the way to go? i have a little experience in java and html
>>
>>53873682
it's a huge topic, hard to just "learn". if you just want some shit up and running then go to >>>/vg/agdg and use the unity engine. otherwise start with maybe a simple game loop and some graphics library, then learn raw opengl
>>
>>53873656
module Main where

import Control.Concurrent
import Data.IPCVar
import Data.IPCVar.File as File
import Data.IPCVar.Shm as Shm
import System.Posix.Process
import Test.Hspec

main :: IO ()
main = hspec $ do
describe "file backend" $
it "reads and writes values" $ do
var <- File.newIPCVar (10 :: Int)
_ <- forkProcess $ writeIPCVar var 20
threadDelay 2000000
x <- readIPCVar var
x `shouldBe` 20
deleteIPCVar var

describe "shm backend" $
it "reads and writes values" $ do
Prelude.putStrLn $ "shm main.hs:23.."
var <- Shm.newIPCVar (10 :: Int)
Prelude.putStrLn $ "shm main.hs:25.."
_ <- forkProcess $ writeIPCVar var 20
Prelude.putStrLn $ "shm main.hs:27.."
threadDelay 2000000
Prelude.putStrLn $ "shm main.hs:29.."
x <- readIPCVar var
Prelude.putStrLn $ "shm main.hs:31.."
x `shouldBe` 20
Prelude.putStrLn $ "shm main.hs:33.."
deleteIPCVar var
Prelude.putStrLn $ "shm main.hs:35.."

that's the test code taken from ipcvar, but there are a handful of other choices for IPC (dbus, 0mq, ipc [deprecated], thrift, mpi, messagepack)
>>
>>53873523
Maybe I could do something like
let (&>&) op args = (fun x -> List.forall (fun y -> op x y) args)

and use it like
((<>)&>&[8;5])a
in F#.

And maybe a 'or' version too:
let (|>|) op args = (fun x -> List.exists (fun y -> op x y) args)
>>
>>53873682
Write simple shit first like zork and tetris and gradually tackle more complicated projects.

>>53873717
Ever >>>/vg/ing is a bad idea. Unity is overkill for a beginner.

>>53873725
>write
>delete
On what universe is that pure?
>>
>>53873755
>On what universe is that pure?
In any? There's not even a function in that code...
>>
>>53873755
>On what universe is that pure?
the deluded one
>>
>>53873749
this is beyond premature optimization. you could be writing real code ya know?
>>
>>53873782
>writeIPCVar
>not a function therefore Haskell is pure
Kek. I guess Scheme is pure because set! isn't a function too huh?
>>
>>53873818
do you understand the definition of "functionally pure"? obviously the program is allowed to have side effects
>>
>>53873832
Clearly when haskellers talk about purity it means something totally different from when normal people talk about purity.

I'm not sure what the point of Haskell's definition of purity means but in normal languages purity means you can use a substitution model in stead of a state-frame model.

Please tell me what functional purity is.
>>
>>53873444
>x += aArray[i++]

Why is the increment inside the brackets? It seems odd to me that up to this point i have only used "i--" and "i++".
>>
>>53873832
A function is pure if it's independent of state outside the scope of the arguments, right? By that definition, it will always behave the same way when called with the same arguments. Is that definition wrong?
>>
>>53873888
++ following a variable means that the operation isn't performed where its located in the code but at after the rest of the statement is executed.

So think of it as the code being expanded to:
x+= aArray[i];
i += 1;

i++; expands to
i;
i+=1;
>>
>>53873906
>>53873856
both of these definitions are correct. a pure function does not evaluate the side effects, but returns a value that represents the computation of those side effects. when you see
main :: IO ()

that means that main is a value of an IO computation returning a type. if side effects were evaluated as part of the function (such as by using unsafePerformIO or trace, then it would not include the IO in the type signature)
>>
>>53873444
I didn't even think it was possible to have a self-contained for statement with a semicolon.
Every time I've done it accidentally, the loop always goes through the first iteration and ends abruptly.
>>
>>53873957
This makes me more confused. What the fuck is your definition of "evaluate"? How is returning a value that represents computation of side effects not a step in evaluation?

Regardless, you still cannot use substitution models if any side effects appear in code. Thus that IPC code ain't pure.
>>
 int sumArray(int aArray[], int length)  


What is this code saying? Is "length" an operator? How does the code know where the array starts based on this?
>>
>>53874083
length is a second argument
you can change it to some other value to exclude entries in the array
>>
New to web development in general.

Can Django make a website like Cards Against Humanity online or The Resistance Online?
>>
>>53874147
Need a bit of JS too. Don't want to refresh the page each turn.
>>
>>53874230
Okay thanks was wondering if that was the case.
>>
            for (x = 0; x < 800; x++);
foreach (Process proc in processes)
PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_SPACE, 0);
PostMessage(proc.MainWindowHandle, WM_KEYUP, VK_SPACE, 0);
Thread.Sleep(400);


I'm new at C#, so bare with me. The second time I call proc here, it's telling me "the name proc does not exist in the current context." Can you only call the iterator of a foreach loop one time? I'm trying to simulate a keypress of the spacebar 800 times with a .4 second interval inbetween each press.
>>
>>53873957
I was thinking about this in the shower: There is no such thing as pure functional IPC because processes are impure.

(define (pure-function)
(thread-start! (lambda () (display "SN"))))

(begin
(pure-function)
(display "AFU"))

The output of this code is undefined: it could either be SNAFU or the less catchy AFUSN.
>>
Java question, is it me or is this weirdly worded...

Write a program that lets a user enter N and that outputs N! (meaning N*(N-1)*(N-2)*...*2*1). Hint: Initialize a variable totalValue to N, and use a loop variable i that counts from N-1 down to 1.

import java.util.Scanner;

public class ElectionYears {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int totalVal = 0;
int userInt = 0;

// FIXME: Ask user to input an integer, store in userInt

totalVal = userInt;
// FIXME: Add while loop that counts down to 1, updating totalVal

System.out.println(userInt + "! is " + totalVal);
}
}
>>
>>53874428
You gotta write a function that computes a factorial of a number. It's pretty easy write a recursive function of the form f(x) = 1 if x=0; x*f(x-1) else.

As for the other bit, it makes perfect sense. You gotta use scanner to capture an int from the command line. It's something like scnr.readinteger(), but just look in an API. It's been 5 years since I've taken a Java course so I don't remember the name of that field.
>>
>>53873416
Not an anime character.
>>
>>53874480
>using a recursive factorial function
>>
>>53874510
>being a preoptimizationfag
>>
>>53874530
>anon, is this bogosort?
>FUCKING PREMATURE OPTIMISATION FAGGOT LOOK AT THIS QUOTE DONALD KNUTH SAID I SHOULD WRITE SHIT CODE
>>
>>53874100
Such as
 int [0,1,2,4] 
?
>>
>>53874554
>not using sleepsort
>>
>>53874560
>implying sleep sort isn't top shit
>>
>>53874554
There's nothing wrong with bogosort until performance becomes a problem. Which would probably be immediately for anything larger than 10 entries but still.
>>
>>53874480
Thanks, I think I understand what it's trying to get me to do, but the way it's all asked gets me confused at first sight.
>>
>>53874574
>Literally unbounded worst case
If you seriously believe what you said, you should actually kill yourself.
>>
Why won't this work?

   private boolean emptyFields()
{
if(jtf1.getText() == "")
{
showStatus("Sales person field cannot be empty");
jtf1.requestFocus();
return true;
}
else if(jtf2.getText() == "")
{
showStatus("Product field number cannot be empty");
jtf2.requestFocus();
return true;
}
else if(jtf3.getText() == "")
{
showStatus("Sales amount field cannot be empty");
jtf3.requestFocus();
return true;
}
else
return false;
}
>>
>>53874588
>until performance becomes a problem
>which would probably be immediately
Besides, bogosorting one element is not unbounded. And technically bogosorting elements with pseudorandom number generation is never unbounded.
>>
>>53874595
other codes

   public void actionPerformed(ActionEvent e)
{
showStatus("");

if (e.getSource() == submit)
{
if (emptyFields() == true)
return;
else
{
int sales_person = Integer.parseInt(jtf1.getText());
int product_number = Integer.parseInt(jtf2.getText());
double sales_amount = Double.parseDouble(jtf3.getText());

// ---------------------------------
// Error checking using given ranges
// ---------------------------------

if (sales_person < 1 || sales_person > 4)
{
showStatus("Sales person number must be in the range 1 to 4");
jtf1.requestFocus();
return;
}
else if (product_number < 1 || product_number > 5)
{
showStatus("Product number must be in the range 1 to 5");
jtf2.requestFocus();
return;
}
else if (sales_amount < 0.01 || sales_amount > 0.99)
{
showStatus("Sales amount must be in the range 0.01 to 0.99");
jtf3.requestFocus();
return;
}
} // End ELSE for no empty fields
} // End IF for Submit button click
else if (e.getSource() == clear)
{
jtf1.setText("");
jtf2.setText("");
jtf3.setText("");
jtf1.requestFocus();
} // End IF for Clear button click
}
>>
>>53874607
depends what generator
>>
>>53874595
>>53874613
use linux
>>
>>53874625
Yeah I realized what I was envisioning wasn't bogosort.

If you were to map every permutation of the input to a number, then you would be guaranteed to eventually finish with a true pseudorandom generator, i.e.

(define (not-bogosort alist)
(let* ((permutations (all-permuatations alist)) (attempt (list-ref permuatations (random 0 (length permutations))))))
(if (sorted? attempt) attempt (not-bogosort alist))))


A pseudorandom number generator that doesn't eventually touch every value in the set isn't really a working one. Its distribution is incorrect from the expected one.
>>
>>53874045
It's "pure" because it's written in Haskell, like a program which is a single class with a single method and only class variables is automatically OO just because it's written in Java (or Smalltalk, if you don't like Java).
>>
>>53874595
Bump. Even with all text fields empy, it still returns false.
>>
>>53874795
check that getText actually returns a "" instead of a null
>>
>>53874795
have you tried with a null instead of ""?
>>
>>53874826
>>53874831
I've substituted null for "" and I still get false. I tried clicking the clear button to initialize each text field as "" as well and emtyField() still comes up with false.
>>
>>53874857
Here's the preceding code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DollarStore extends JApplet implements ActionListener
{
private JLabel n1 = new JLabel("Enter sales person number (1-4): "),
n2 = new JLabel("Enter product number (1-5): "),
n3 = new JLabel("Enter sales amount (0.01-0.99): ");
private JTextField jtf1 = new JTextField(5),
jtf2 = new JTextField(5),
jtf3 = new JTextField(5);
private JButton submit = new JButton("Submit"),
clear = new JButton("Clear");
private JTextArea jta = new JTextArea(8, 58);
private static double sales_totals[][] = new double[4][5];
private static double product_sales_totals[] = new double[5];
private int entries = 0;

public void init()
{
setLayout(new FlowLayout());

add(n1);
add(jtf1);
add(n2);
add(jtf2);
add(n3);
add(jtf3);
jta.setFont(new Font("Courier", Font.BOLD, 10));
jta.setEditable(false);
add(jta);
add(submit);
add(clear);
submit.addActionListener(this);
clear.addActionListener(this);
}
>>
>>53874879
and for applet html

<HTML>
<APPLET CODE="DollarStore.class" WIDTH=400 HEIGHT=230>
</APPLET>
</HTML>
>>
>>53874826
>>53874831
>>53874879
>>53874891
Whoops, I got it. I should use jtf1.getText.equals("") instead of jtf1.getText == ""
>>
>>53874045
you can most definitely substitute with monadic IO. if i define an action in the IO monad:
doSomething :: IO ()
doSomething = do input <- getLine
putStrLn ("You said: " ++ input)

and then run it:
main :: IO ()
main = doSomething

notice that doSomething is never applied to anything. in fact, since no -> is present in the type signature, you know that it's not going to be applied to something (unless IO a is defined as b -> a)
in fact, the following:
main :: IO ()
main = do doSomething
doSomething

is replaced with
main :: IO ()
main = do input <- getLine
putStrLn ("You said: " ++ input)
input <- getLine
putStrLn ("You said: " ++ input)

because those are the unapplied values of doSomething.
with the monads unsugared it might be a bit more clear:
main :: IO ()
main = getLine >>= \input ->
putStrLn ("You said: " ++ input) >>
getLine >>= \input ->
putStrLn ("You said: " ++ input)

in this code, you'll see that the functions (>>=) and (>>) are chaining together the different actions into one, single IO action.
>>
>>53874595
Doesn't Java require you to use a compare function? IIRC, using == compares the references for strings, not the value.
>>
>>53875053
Yep, I just figured that out as i said here >>53874969
>>
>>53874998
That's how a procedure is defined in Algol. By definition, any procedure can be substituted for its body.
>>
how in the fucking fuckity fuck does cmpsd work?
>>
>>53874998
IO isn't using multiple processes in that case though.

Processes are impure in general, so tainting your code with forks is going to soil it. See >>53874391
>>
Where can I find the math module for Python?
>>
>>53874499
I meant link as in URL you tard.
Give link (URL) to the book please.
Or at least a title.
>>
I need to use a method on an object on the top of a stack so I do
someStack.peek().someMethod();

then I need to pop that object so when I do it all again it werks

however when I do
someStack.peek().someMethod();
someStack.pop();

it doesn't work. (the method doesn't remove the object from my screen object whereas removing the statement that pops the object does remove the object
If I do
someStack.peek().someMethod();

then later (from another keystroke or whatever) I do
someStack.pop();

It all works as intended


So apparently I need some way to only pop() when someMethod() completes
Any idea how to do this in Java or do I have to use some hacky way using callbacks?
>>
Just finished the codeacademy Ruby Section.

Whats a good path to making money in programming? Aka getting a cushy tech startup job/internship.

Any good learning resources would be great
>>
>>53875088
turns out I wanted comisd
>>
>>53875371
>>Whats a good path to making money in programming?
learning java/VB

:^)
>>
>>53875209
import math>>53875284
>>
>>53875399
I mean the documentation like the other modules in lib
>>
>>53875143
doesn't matter the order for that, the forking is the IO process that gets sequenced. execution of side effects is outside the scope of the program itself. substituting the actions in the correct order will result in the same code being executed, but the side effects may occur in different orders
>>
sqrt:
push rbp
mov rbp, rsp

movsd xmm1, xmm0
movsd xmm0, [double_one] ; how the fuck do I do floating point immediates in nasm?

begin_loop:
movsd xmm2, xmm1
divsd xmm2, xmm0

addsd xmm0, xmm2
divsd xmm0, [double_two]

movsd xmm2, xmm0
mulsd xmm2, xmm2
subsd xmm2, xmm1

comisd xmm2, [sqrt_tolerance] ; 0.001
ja begin_loop

mov rsp, rbp
pop rbp
ret

it works

now someone tell me how much of a retard I am and that there's a way simpler way and that I'm doing everything wrong
also what's the deal with fsqrt?
>>
>>53875434
Your conception of what a program is is inane and exists only to insist that haskell is pure. Never change haskellchan.
>>
File: operating-system-logos.jpg (65 KB, 682x511) Image search: [Google]
operating-system-logos.jpg
65 KB, 682x511
>>53872049
So I am in 3rd year and getting ready to graduate. I am in various stages of learning Java, C, C++, C#, Python, HTML, CSS, JavaScript. Lots of languages are clones of each other, so it's going to be easy to learn the top ten languages plus one functional language like F# or Haskell, so I am not concerned about language proficiency.

What I am more concerned about is platform proficiency. I am on Windows 10 with Linux VM's and I have a Windows phone and an Android phone. I'm pretty much shut out of iOS development, which is really high paying, so I will have to buy a Mac if I want to pursue that.

What platforms should I have on my resume when I graduate? I live in a government town (Victoria, BC) so there are .NET government jobs here, but I don't think they give them to new grads. I am going to have to work for a few years before I get that kind of job.

iOS and Android devs make more than .NET devs, but the difference isn't that big in Canada, and I don't see how a mobile dev job will help me get a government job.
>>
>>53875698
You didn't specify what your degree was in, but I'm going to assume it's in codemonkey.

You just answered your question though. If you want to work for the man, then you should put .NET on your resume to get more .NET experience in hopes of being picked up by the man.

Anyways do not focus on 30 million languages. Focus on .NET shit and forget everything else if you want to do .NET.

Interviewers may try to ask in-depth language questions and you don't want to put a language you don't know well down.

I.e. you put C++ on your resume and you don't cast malloc, or put C on your resume and you don't remember to typedef structs or forward declare when you need to.
>>
>>53875752
It's in computer science.

I guess I will focus on .NET then. As a side benefit I can make apps for my PC an phone too.

I sent an email to the government asking them what kinds of skills they look for in hires. I will get a reply some time tomorrow hopefully.
>>
>>53875491
where are all of /dpt/'s x86 programmers?

I spent like two days blindly fucking around with this to help me learn assembly and I want to know if the solution I ended up with is totally fucking retarded or acceptable
>>
>>53875850
Most people use high level languages like C or higher. /dpt/ rarely ever has assembly not to mention you're posting in the middle of the night in americalandhours.

Anyways good night and good luck from Texas, Euroman.
>>
>>53875881
>euro
yeah nah, fuck youse aye
>>
is github down
>>
Anonymous 04/05/16(Tue)01:24:28 No.53868089▶
What is the proper way to generate a PRNG seed for a program which doesn't have to be cryptographically secure? Just using the time combined with some trash found in uninitialized variables seems unreliable.
>>
>>53876976
No?
>>
>>53876998
>proper way
elaborate
time of initialization is the most common i think
>>
>>53876998
>TFW you actually copied the title bar
I am an idiot of incredible proportions.

>>53877029
I want to ensure that every time the user runs the program the seed is reasonably random regardless of use habits. System time seems problematic because certain users are going to consistently run the program at a similar hour on a daily basis, biasing the seed.
>>
File: future.webm (1 MB, 480x640) Image search: [Google]
future.webm
1 MB, 480x640
Ask your much beloved programming literate anything.

>>53875491
there no instruction for loading an immediate value in a sse/avx register.
why not using sqrtss ?
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_sqrt_ss&expand=4935,4935

>>53873444
this should be a little faster
int sumArray(int const * aArray, int length) 
{
int x = 0;
int const * const limit = aArray + length;
while (aArray < limit)
x += *(aArray++);
return x;
}


>>53876998
uint64_t getSeed(void)
{
struct timespec t;
uint64_t seed = 0;
for (int i = 0; i < 10; ++i)
{
clock_gettime(CLOCK_MONOTONIC, &t);
seed ^= seed >> (t.tv_nsec & 31);
seed += (t.tv_nsec & 0xFF) << ((seed % 8) * 4);

}
return seed;
}
>>
>>53877267
>there no instruction for loading an immediate value in a sse/avx register
I mean surely there must be, but nasm wouldn't stop complaining until I did that

>why not using sqrtss ?
trying to learn m8

is there a better implementation of that specific method or did I do it 'right'?
>>
>>53877323
>>53877267
wait, did you mean 'is there no', or 'there is no'?
>>
File: IMG_20160405_155742.jpg (34 KB, 1115x179) Image search: [Google]
IMG_20160405_155742.jpg
34 KB, 1115x179
Why is this happening?
>>
>>53877412
#include <stdlib.h>
>>
>>53877453
ah thanks
>>
File: Screenshot_20160405_204545.png (23 KB, 499x214) Image search: [Google]
Screenshot_20160405_204545.png
23 KB, 499x214
>>53875491
wow GCC -O3 gives me almost exactly the same code for
    do
guess = (guess + x/guess) / 2;
while ((guess * guess - x) > 0.001);

(it seems to have loaded 0.5 into xmm4 to multiply, instead of dividing by 2)
spoopy

if literate-kun is still here, what's the difference between movsd and movaps? The manuals pretty much look like encrypted polish to me
GCC used movsd to put constants into registers, but movaps to move from one register to another

also what's the point of ucomisd and rep ret?
>>
>>53877609
switching movsd to movaps seems to fix a problem I was having with large inputs causing the program to hang, so that's good
>>
>>53873682
I recommend Game Coding Complete (4th edition) by Mike McShaffry and David Graham.

Assuming you know programming systems at its basic they give a very good introduction and guide into how to design your engine to share a lot of code usually.

They do C/C++/C#.

They do a few things I don't like like using Lua as a scripting language when they could just stick to C/C++ and import dll's/dynamic-link libraries as their scripting service. Doesn't exactly have any downsides, except if windows is funky I guess.

They don't teach you game design. I consider that a good thing. If you have absolutely no idea what makes a game good I recommend The Art of Game Design: A book of lenses. I find that it promotes a good view on game design but I fear it might stifle creativity by putting requirements on the project at the wrong time. Like they say that you should focus on the player experience, which is primary. But you're often helped to find better game-play elements if you ignore that and make things interesting to begin and then adjust them to fit player needs. I don't have any complaints on what's taught just the priorities.

Both books are a bit silly. It's worth noting that you should probably limit your scope significantly for early projects. If you just want to pump out a game you can pick up something like gamemaker and produce something rather quickly. If you actually want to learn the craft books like these are good because they focus on the learning rather than a specific game. The stuff they teach carries over better than your experience building a game. So they're a very good start.

I recommend you do some programming on the side though. Because it's rather demoralizing to have been reading theory and having to be distracted because you don't remember language syntax at all.
>>
>>53872584
Exactly. For example, when we first got into databases in school, what I did was grabbing the Monster Hunter Database and started making simple python scripts to find for example with a given amount of slots what kind of skills I could add into my set, stuff that tools written by other people didn't do.
>>
>>53877751
And this was just a basic cmdline tool that I shared with some friends who where using it quite often.
>>
What are the strengths of go? What sort of backend services are places using it for?
>>
>>53877609
>>53877636
movapd move two double words (128 bits) from an aligned address
movupd move two double words (128 bits) from an unaligned address
movsd move one double words (64 bits) from an address (aligned or not is irrelevant since is just one element).
>>
File: kitten.jpg (411 KB, 1600x1200) Image search: [Google]
kitten.jpg
411 KB, 1600x1200
What 3 programming languages would you recommend to your
> 1. best friend
> 2. worst enemy
who looks for a job?
>>
>>53877996
1. F#
2. Java
>>
File: Bmi17lN.jpg (295 KB, 897x1200) Image search: [Google]
Bmi17lN.jpg
295 KB, 897x1200
>>53877996
racket
php
>>
ok i am in a pickle here.
so i got this bunch of classes say
 class Node{}
class plus: Node{}
class integer:Node{}
class var: Node{}

so basically a tree of inheritence.
each of the son nodes can interact with each other. each act differently depending on who it is paired with.
say
 int something(Node a,Node n);
int something(Node a,plus n);

and so on.
what is the best way to do this?
i'm using C++, and i looked into patterns,
the visitor pattern came close to it yet i have to branch in a lot to achieve the result i need.
basically i want something to make it work without having the code go into 3 or more calls into the stack to start the actual function.
how do i go on about this?
>>
>>53878059
what do you actually want, double/triple dispatch?
either
a) use a tag (much nicer)
b) once you've virtual called on an object, you know its type - so then you virtual call on one of the other objects, and then you know its type and the other one's types - then you do another virtual call

that's three virtual calls and you need a shit ton of fucking overloads
>>
>>53878092
i'm okay with spending time on having a fuck load of overloads. for now i'm only going for a double dispatch.
i think i forgot to add that the father Node is going to be used as a pointer, but i guess it should be obvious since i mentioned the visitor pattern.
I'm looking into what you mentioned.
i was contemplating using the boost library's variant, was it? but i thought that was going too far.
>>
http://zelda30tribute.com/

>b-but webdev can't be real programming, a-anon
>>
>>53878128
variant gives you a tagged union, so that'd be ok too
if you were doing it in another language that's probably what you'd use
>>
>>53878140
not webdev senpai
>>
File: out.webm (3 MB, 793x443) Image search: [Google]
out.webm
3 MB, 793x443
I can't figure out how to make a chroma-key shader.
Pic not related really.
Shader is here
https://www.shadertoy.com/view/4dcXRS

I just have no idea how I'd negate the green properly.
>>
File: 1459728323816.jpg (47 KB, 650x427) Image search: [Google]
1459728323816.jpg
47 KB, 650x427
So, how do I get into this shit? Reading this thread is like reading a different language.
>>
>>53878166
>webgl
>not webdev
>>
>>53874296
>
            for (x = 0; x < 800; x++);
foreach (Process proc in processes)


What the fuck are you doing?

Use brackets.

for (x = 0; x < 800; x++)
{
foreach (Process proc in processes)
{
PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_SPACE, 0);
PostMessage(proc.MainWindowHandle, WM_KEYUP, VK_SPACE, 0);
Thread.Sleep(400);
}
}
>>
>>53878207
It's just arithmetic and a few control statements usually.
This isn't too bad if you're in a hurry
https://www.stavros.io/tutorials/python/
>>
>>53878207
Read an intro to programming in whatever language book.
>>
>>53878252
>I will assume that you are already familiar with programming and will, therefore, skip most of the non-language-specific stuff.

Nice recommendation for a newbie, faggot.
>>
>>53877412
don't cast the return of malloc.
>>
>>53872228
C#: not even once
If you're normal you use Java
>>
>>53878278
Ok I guess you need to hear "programs usually execute sequentially. What you're writing is a list of tasks".

I posted what I'd want as an introduction anon. It just takes some concentration. You even have people to ask here.

Guess it also doesn't say that he's using the python interactive shell. You write a line of code and then hit enter, machine interprets the code and prints the result.
>>
>>53878294
normie get out ree, etc.
>>
>>53878297
I'm not even the newbie you posted that for, as I doubt he even got to that point given how shitty a beginners guide that is.

Wouldn't something like Learn Python the Hard Way be more suitable for someone who has never programmed in their life?

>>53878207
http://learnpythonthehardway.org/book/preface.html
>>
>>53877849

Cloudflare and Dropbox both made an issue of running most of their network services on Go.


Lots of people have jumped on https://github.com/gogits/gogs because it's a lot easier to say "run this binary" than "install Ruby, now learn how to manage Rails so you can deploy Github". The compiled binary has a lot of advantages.

(I haven't used Go as a dev, just an end user of these products. I also like using https://github.com/goadapp/goad.)
>>
>>53878280
I don't follow religions
>>
>>53878324
>Wouldn't something like Learn Python the Hard Way be more suitable for someone who has never programmed in their life?
Maybe if you just skim through the first 10 exercises.

I'm a fairly practical guy so I prefer experimentation. Since that's a large part of the language presented and a good reference for a newbie who's willing to learn.

In my experience teaching kids (on my spare time) they're far more receptive to exploration than following instructions. It's also obvious it sticks better. You see how excessive learnpythonthehardware is on printing? You see that everywhere, it's incredibly boring and doesn't keep an enjoyable phase for learning. It's as soul crushing as first grade math.
>>
do not start with python, it will ruin you for life
>>
>>53878377
just giving out advice in /beginner programmer general/ :^)
>>
>>53878380
You raise a good point about printing everything. I suppose the intent is to focus on the logic and the feedback is just for testing.

To this end, I generally recommend Murach's C# for many newbies, as it pushes you straight into basic GUI programming, albeit from a more business-focused perspective (financial stuff, database integration).
>>
File: download (39).jpg (6 KB, 225x225) Image search: [Google]
download (39).jpg
6 KB, 225x225
I just got QPython for Android

Is it good or no?

Also, I'm >>53878207
>>
File: memes.jpg (46 KB, 695x431) Image search: [Google]
memes.jpg
46 KB, 695x431
>>53878425
>python
no
>>
>>53878380
Also introducing files before functions make little sense to me. It's as problematic as introducing classes in languages where they're required.
>>53878406
I started with C. Now I get syntax errors on semicolons, braces and everything all the time.
>>53878416
>I suppose the intent is to focus on the logic and the feedback is just for testing.
Not sure what the intent is. He says it's building a skill based on repetition. He's building syntax understanding at best.
>basic GUI programming
I don't like that start. Mainly because traumatic childhood memories. Mom and dad gave me a book on Visual Basic and I thought I was expected to get it even though I didn't know basic. It presumed you knew basic. It might engage some people but it doesn't promote understanding. What I think you should have if you want to utilize visual feedback is some very rudimentary library that just writes to a drawbuffer for you. So you can build the logic of the program there (draw->display->clear->simulate...). It's not a good place to "start" though, you need at least function+control statement understanding and everything below.
>>53878425
It works. Wouldn't type on a phone though.
>>53878461
There's literally very little wrong with python.
>>
File: plshelp.png (16 KB, 432x299) Image search: [Google]
plshelp.png
16 KB, 432x299
I was given this task to do for uni in JavaScript

(Create table that looks like pic related)

What's the best way of going around doing something like this?
>>
File: byah6Aq.png (14 KB, 516x198) Image search: [Google]
byah6Aq.png
14 KB, 516x198
>Xamarin now free (as in beer) and going MIT licensed open source
>Mono fully released under MIT, including some previously proprietary components for ARM performance and OSX
>Red Hat Enterprise Linux now including .NET as a first class dev option. Azure now has RHEL VMs, RHEL dev is free now.
>Red Hat, Unity, JetBrains, and Mono now part of the .NET Foundation.
>Ubuntu/Windows, or as I've taken to calling it, Ubuntu+Windows is becoming a thing
>Bot Framework, Cognitive Learning service APIs released

.NET developer or not, these are good things.
>>
>>53878482
You mean like produce the picture or HTML code for it or what?
http://www.w3schools.com/html/html_tables.asp
>inb4 >w3schools
Doesn't matter.

If you're looking to generate them based on some input its easy too, pick a language (python) and just print the HTML as you go rather than fussing with file output and just send the output to a file in the command prompt
i.e.
./program >file.html
.
>>
>>53878425
It's good for my needs
I use it to run a script that was normally constrained to Desktop so yeah, it's pretty good.
>>
I've got an assignment where I have to convert a bunch of text to an xml document. I opted to write the converter python, out of that or java. The input file has strings like
(aka "#ñÐÒÁ×Á" (2013))    (Russia) (original Cyrillic KOI8-R title)

If I open the file in Notepad++, I can just change the character set to KOI8-R and it shows the text as Япpaвa, which it should be. If I try to add the converted xml file in basex as a database, it complains saying that the 2nd byte of a 4 byte utf-8 sequence is invalid. If, in the converter code, I open the files with
inFile = codecs.open("movie-list.txt", "r", "utf-8")
outFile = codecs.open("movies.xml", "w", "utf-8")

instead of
inFile = open("movie-list.txt", "r")
outFile = open("movies.xml", "w")

python says the same thing, since ñÐÒÁ×Á is "xF1 xD0 ..." and xD0 can't follow xF1, yeah?

Essentially my question is what the fuck am I doing? How do output unicode properly in python? How do I read it in? I thought I'd just be able to leave the strings like ñÐÒÁ×Á as they were, since we're being marked on xml and xqueries, not encoding, but I can't run the xqueries on the xml database if basex refuses to open them.
pls halp
>>
>>53878482
>>>/g/wdg/
>>
>>53878509
Microsoft is literally the best big company, can't believe everyone always shits on it
>>
in the header:
struct A{
int x;
int y;
};

class B{
private:
static const struct A array[2];
};


in the code:
const struct A B::array[0] = {0, 1};
const struct A B::array[0] = {1, 2};


And I get conflicting declaration error. Why?
>>
>>53878527
I assume it's supposed to be dynamically made
I already know how HTML tables are done, but I'm pretty sure that it has to be generated through code.

Also as I was typing this I figured it out

in case anyone cares (probably no one)

document.write("<table border='1'><tr><th>a</th>")
for (var i = 100; i > 0; i = i - 10) {
document.write("<th>" + i + "</th>");
}
for(var j = 10; j > 0; j--){
document.write("<tr><th>"+ j * 10 + " </th>")
for(var k = 10; k > 0; k--){
document.write("<td>" + j * k * 100 + "</td>");
}
}
document.write("</tr></table>")

thanks anyways m80
>>53878550
I just assumed since it was more programming than actual webdev that it could fit in there
>>
>>53878551
It's because they're so antagonistic to everyone who works with them aside from business plebs. Everyone should hate every company really.
>>
>>53878557
C or C++?
>>
>>53878551
Bad reputation.

Refusal to believe they can do anything right.

So much neat things to play with on C#/F# now.

Write one application + GUI and it runs on Win10, Xbone, PS4, Android and iOS. That's insane.
>>
>>53878461
>entire machine learning is python
>entire deep learning is python
>neural nets is python
Retard detected.
>>
>>53878557
you're declaring the 0th element twice
>>
>>53878557
Obviously in the code I use array[0] and array[1], I copy-pasted that line and forget to modify the index.
>>
>>53878569
>Everyone should hate every company really.
crowdconfusesbirdfor800delegates.png
>>
How do you get a for loop to create items on the same line? I'm trying to a make a Hangman program in which the program generates a given number of spaces, depending on the length of the word picked for the game.
You'll have to excuse the rudimentary code, I wrote it quickly to figure out the concept:
 Dim a As Byte

For a = 0 To spaceLength
Console.WriteLine(spaceLength.ToString & " ")
Next
Console.WriteLine("▀")

To explain quickly:
spaceLength is the word-length - how many letters are in the word; this is used to determine how many spaces need to be created. The variable is determined by a ran-gen word from an array.

The ASCII block is just to be a placeholder, so I can visually see what has been generated. The problem is that each space is generated on a new line every single time
>>
>>53878557
>conflicting declaration error
What line.
>>
>>53878594
Just use 'Write' instead of 'WriteLine', ya dingus.

Why are you learning VB in 2016? F# and C# exist.
>>
>>53878594
use Console.Write instead of Console.Writeline. I think
I don't remember what language this is but I've written this kind of code.
>>
>>53878604
I have to learn VB for a class I'm taking, but I'm gonna drop it the moment I can.
I'm currently using C++ as my main language, I just have to write the assignment in VB
>>
>>53878615
What shitty college do you go to? I want to make sure no one I care about ends up there.
>>
>>53878615
What's this PC bullshit? Why would anyone force you to extend into other languages just for the heck of it?
>>
>>53878615
For the sake fo your own sanity write everything in c# and run it through a converter.
Just because you have to submit work in the language does not mean you have to live like a filthy vb peasant.
>>
>>53878638
>For the sake fo your own sanity write everything in c# and run it through a converter.
Holy shit, don't do this.

C# is thousands of times better, but you'll end up confusing yourself even more if you do this, especially if you have to regurgitate VB-specific things back on a written test.
>>
>>53878615
>I have to learn VB for a class I'm taking, but I'm gonna drop it the moment I can.

There are converters that can translate C# to VB perfectly. Learn C# and turn in assignments post-conversion.
>>
How does getting reverse of linked lists in python actually works?

class Node:
def __init__(self, cargo=None, next=None):
self.cargo = cargo
self.next = next

def __str__(self):
return str(self.cargo)

def print_backward(list):
if list == None: return
head = list
tail = list.next
print_backward(tail)
print head,

print_backward(node1)


Say if I already put 1,2 and 3 in node1, node2 and node3 respectively.
Whats the process behind it printing 3,2,1?
>>
>>53878579
none of this is programming
>>
>>53878570
>class B
I wonder

>>53878601
all code lines

The solution was:
const struct A B::array[2] = {
{0, 1},
{1, 2}
};
>>
>>53878699
Reversing the list basically
The linked lists I use are a copy of sicp lists where you just do cons(3, cons(2, cons(1, none)))

Implemented as a ensted array (3 , ( 2,( 1 none)))

OR you could dó a doubly linked list where you have a next and a previous pointer
>>
>>53878207
https://docs.oracle.com/javase/tutorial/

>>53878425
please don't pick python as your first language, it's SHIT

>>53878579
>entire epic meme is python
>>
>>53878696
see
>>53878645
>>
>>53878699
> Whats the process behind it printing 3,2,1?
Because `print_backwards` is before `print head,`
>>
>muh machine learning
>muh deep learning
>muh neural nets
seriously faggots why are you so interested in this crap, it's like you have way too high expectations of what you can do with it
>>
>>53878557
>>53878731
const struct A B::array[0] = {0, 1};
should be
const A B::array[0] = {0, 1};
>>
>>53878788
also you shouldn't have struct in the class declaration either

the compiler knows A is a type, putting struct before it is invalid
>>
>>53878699
Here's the sequence of what's happening. Maybe looks messy but it helped me understand recursion better than most explanations.
printbackwards(node1)Calls->printbackwards(node2)Calls->printbackwards(node3)Calls(NullNode)->nullnodeReturns->printbackwards(node3)printStatement->printbackwards(node2)printStatement->printbackwards(node1)printStatement
>>
>>53878796
Meant to post like this:
printbackwards(node1)Calls->
printbackwards(node2)Calls->
printbackwards(node3)Calls(NullNode)->
nullnodeReturns->
printbackwards(node3)printStatement->
printbackwards(node2)printStatement->
printbackwards(node1)printStatement
>>
>>53878787
It's really cool shit.

Being able to examine the sentiment, keywords/phrases, and general discussion amongst each of our clients' service tickets is pretty neat.

It's also the first steps in creating useful conversational bots.
Thread replies: 255
Thread images: 36

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.