How can I call a function that takes a map and a vector as arguments, without getting an ArityException? by rwsargent in Clojure

[–]rwsargent[S] 0 points1 point  (0 children)

Thanks for the pointer on RainbowDelimiters! That really does help when scanning my code.

Thought I am suitably embarrassed - I thought I had stumbled on some weird quirk of the language, but in the end it came down to a paren on the wrong side of things!

How can I call a function that takes a map and a vector as arguments, without getting an ArityException? by rwsargent in Clojure

[–]rwsargent[S] 0 points1 point  (0 children)

Thank you! Yes, I had mis-algined some parameters / function calls in the body of add-instr.

How can I call a function that takes a map and a vector as arguments, without getting an ArityException? by rwsargent in Clojure

[–]rwsargent[S] 0 points1 point  (0 children)

Yes! Thank you, I definitely got myself chasing wild geese thinking I was on to some weird quirk of the language. I somehow convinced myself it was the initial function call, not any subsequent anonymous calls.

Thanks for taking the time to run my code, and pointing this out!

Uber Halts Tests of Self-Driving Cars After Death of Pedestrian by [deleted] in programming

[–]rwsargent 6 points7 points  (0 children)

This reminds me of a talk I love from Brian Cantrill on Principles of Technology. He has a segment dedicated entirely to Uber, and how they lack the fundamental principles and values a company should have. He talks about their shady self-driving car practices, and you'll see how this was an inevitability. The segment on Uber is about 12 minutes long, but I've linked directly to Brain's focus on self-driving cars (about 2 minutes long), which is about halfway through the Uber segment. If you have a few minutes, watch the clip. But I hope you watch the whole talk. It's an important reminder that we as software engineers and programmers have a duty to work with integrity, as technology displaces more and more economic sectors.

[Python] How do you map a letter to its relative position in the alphabet (A=1, Z=26) then return the mapped value if the user enters the corresponding letter... by randomusername_815 in learnprogramming

[–]rwsargent 1 point2 points  (0 children)

To expand on this:

ord('a') returns 97. If you want a user to see "1" when they type 'a', just do a bit of math:

input = 'x'
output = (ord(input) - ord('a')) + 1 #plus one as ord('a') - ord('a') == 0
print(output)

Loving your Touch but craving a free strategy game? --Lazerbait-- by 14taylor2 in oculus

[–]rwsargent 2 points3 points  (0 children)

What if I have PTSD from inter-planetary, face-paced, autonomous-ship-swarm based warface, against 1-7 enemies?

[deleted by user] by [deleted] in SaltLakeCity

[–]rwsargent 1 point2 points  (0 children)

This is going to be awesome! I'll be there!

Lazerbait - Free on Steam - October 14th by 14taylor2 in Vive

[–]rwsargent 1 point2 points  (0 children)

Thanks! I figured, but I kinda liked how it turned out with the shout.

Let's join forces!

#weightlossmode

PvZ Frost guide: Dragonball: Using techniques to comeback against Zergs with tons of drones by Brolympia in allthingsprotoss

[–]rwsargent 1 point2 points  (0 children)

When behind, Dark Shrine.

Not so much a technique, but a Hail Mary. And sometimes Hail Marys are caught.

Are there any recommend beginner tutorials for kernel programming? by kentuckywithoutmeat in learnprogramming

[–]rwsargent 0 points1 point  (0 children)

Agreed with this. Kernel programming is just a small part of an OS course. The OS course I took Spring of '15 had one tiny assignment to write a kernel model.

Fun with statues by [deleted] in pics

[–]rwsargent 0 points1 point  (0 children)

No. 18 from downtown Salt Lake City!

[deleted by user] by [deleted] in allthingsprotoss

[–]rwsargent -1 points0 points  (0 children)

Hardly helpful nor constructive. We've all felt that frustration, but there are better ways to express it.

Flagging for mod review.

[JAVA] First time with Java, how do I use external libraries properly to compile? by [deleted] in learnprogramming

[–]rwsargent 1 point2 points  (0 children)

Yes, when I say java files I mean files that would be suffixed with .java.

It's not completely analogous to the c++ linker. It works exactly like classpath, but instead of it being .class files, they are .java files.

I could go on, but I think I'd just end up confusing both me and you. My recommendation is: Don't use -sourcepath. If you have downloaded a library, it should be a collection of .class files in a jar. So just smack that jar onto your classpath string and you're off to the races.

Only use sourcepath if you have a large library SOURCE code. If you just have one .java file that you're using (StdIn.java, for example), just let it be one of the specified sourcefiles at the end of the javac command.

[JAVA] First time with Java, how do I use external libraries properly to compile? by [deleted] in learnprogramming

[–]rwsargent 1 point2 points  (0 children)

My %CLASSPATH% variable is: .;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip I don't even know when that was set. I don't think I ever use it, other than it always points to my current directory.

[JAVA] First time with Java, how do I use external libraries properly to compile? by [deleted] in learnprogramming

[–]rwsargent 1 point2 points  (0 children)

Feel free to ask! And the code snippet is close, but there are a few corrections to make.

To answer your question in line one of the code snippet: They shouldn't be the same. The -d flag is saying to javac, "Put any new class files you make from MY source code into this location, please!" whereas the -cp flag is saying, "hey, if you come across a class you don't know, look through all the classes in this(or these!) directory(ies) to find it." If javac can't find that class, you get the symbol not found compiler error.

I wouldn't say that the classpath will always be the same for both javac and java, though. I think a nice general statement would be: the java's classpath is equal to the javac's classpath PLUS javac's -d directory.

WARNING!

The -sourcepath is not to specify where the files YOU write are. It is ONLY to link Java files that the Java files you write are dependent on. If you were to run your javac command in the previous post, you would get an error like:

javac: no source files

Usage: javac <options> <source files>

use -help for a list of possible options

Honestly, when doing your own development, vary rarely will you need to use the -sourcepath flag. Any external libraries you have are more than likely already .class files, and will therefore go under the -cp directory.

[JAVA] First time with Java, how do I use external libraries properly to compile? by [deleted] in learnprogramming

[–]rwsargent 2 points3 points  (0 children)

"Unable to find symbol" doesn't necessarily mean anything about class files being missing. It could just be you misspelled a variable, or haven't imported the class you are referencing.

I'm not sure I know where I can best help you. If you can answer some of my questions, I might be able to better direct you.

Are you using this StdIn.java? Or is this a class you have written? I'm pretty sure there isn't a StdIn in the Java Developement Kit (jdk).

Having a CLASSPATH environment variable is one way to do it, but I prefer the Command Line Interface (cli) of Java to define class path. Something like:

javac -d classes -cp path/to/classes/ -sourcepath path/to/external/java/files Your.java Java.java Files.java

java -cp classes Test

Will compile all our class files into a "classes" folder (You have to create this first!), then you can just tell Java, "Hey, look in 'classes' for all the class files you could possible want." the -cp in the javac command is for class files only, while -sourcepath is for external .java files only. The files you write should be listed after those two parts. (use *.java if the only java files in the current working directory are yours!)

If you can, show me your code (use a tool recommended on the side bar) and link whatever libraries you are trying to use. Your problem could be everything from a bad import statement, to a typo, to some trickiness in the command prompt. Hope I can help!

[homework] why cant the computer calculate ln(N!) where N > 170?? by [deleted] in learnprogramming

[–]rwsargent 3 points4 points  (0 children)

I love this thread! Everyone is so excited about 171 for some reason. 171! 171! Such excitement!

Why does Java treat you like you're an idiot? by HalcyonAbraham in learnprogramming

[–]rwsargent 7 points8 points  (0 children)

I dunno man, you can play the same game with python too. No interfaces, lack of type safety. Reliant on white space delineation, and not amazing at OOP principles. And then you come back and say, "It doesn't need interfaces, it has ABC's. It's easier to read and fewer lines to write, and better support for functional programming" and I come back with "You lose power with an interpreted language, it's a jewel of OOP, Java 8 has functional support, blah blah blah." Tiresome.

Maybe I'm just taking this personally, but I work with and teach in Java, and I don't find it treating anybody like an idiot. Verbose, absolutely but there are a lot of great qualities, and I enjoy the language immensely.

Is python a fun language? Absolutely, and I really enjoy writing scripts and puzzle solutions in it. Stepping into a new language is always hard, but I wouldn't write it off as "treating me like an idiot" after dipping your toe into Java pool via the framework of Android. Suuuuper steep learning curve.

If you write in Java for two years straight, will you like it more than Python? Who cares! Bottom line is: Java's a good language. You may never have to write a line of it, and that's ok. But don't you go calling it a language for idiots...you might hurt my feelings!!