[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
FUNCTION(Input = string) IF (length(string) == 1) print (string)
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: 17
Thread images: 2
FUNCTION(Input = string)

IF (length(string) == 1)
print (string)
ELSE
FUNCTION(input = string except for its first character)
END

print(first character of string)

END OF FUNCTION

This isn't Java but when you do this in Java it successfully prints the characters of the input string backwards.

So how does this work?
>>
it's called recursion. just fucking read about it and follow the code's path you autist, it's so easy to figure, Jesus.
>>
File: 1457603867919.jpg (34 KB, 540x474) Image search: [Google]
1457603867919.jpg
34 KB, 540x474
OP you may be autistic
>>
>>54741421
Why did you post a picture of Zizek when you are clearly too stupid to have understood a single one of this thoughts?
>>
>>54741421
Wait so you understand it enough to write appropriate pseudocode but you don't know what it does? What the fuck
>>
use "abc" as an example

function("abc") calls function("bc") since "abc"'s length != 1, which calls function("c") since "bc"'s length != 1. "c"'s length = 1, so "c" gets printed and function("c") ends. function("bc") is done calling function("c") and prints "b". function("abc") is done calling function("bc") and prints "a".
>>
Its recursive, think of the functions getting called onto a stack, like the other anon pointed out.
>>
It's a call STACK.

Go look up what a stack is
>>
excushe me, *sniff*, I whas wondering why you have posted, *sniff*, my fashe on this thread? I see it and I say: MEIN GOTT, your coding skillsh is certainly not good. Shart with basic stuff first! Eet iz ideology at its finest! *tugs shirt*
>>
>>54741421
>prints string
>then prints the first character of the string

output of function("abc") should be
"ccba
>>
it's called hacking
>>
since this thread is already here;
if I want to read from a .csv file, and I know the format is something like (name of country, population)
Taiwan,23071779
how can I parse through the lines and read the numbers like ints, and let's say test each one?
I'm trying to use the string methods like replaceAll and split but I may be actually retarded so I don't know anymore
>>
>>54744495
there's probably a better solution, but i would start by using regex to find all instances of

<digit> <nondigits> <digit>

and replacing the <nondigits> part with a newline, then summing each line
>>
>>54744848
and i just realized this wouldn't work if the file has nonintegers, so good luck
>>
>>54744495
Change scanner delimiter to ,
Read city name
Read population
Repeat
>>
>>54746025
this is the first thing I tried, but I don't know what's wrong actually
 public static void main(String[] args) throws Exception {
Scanner inFile = new Scanner(new File("list.csv"));
inFile.useDelimiter(",");
while(inFile.hasNextLine()) {
String input = inFile.nextLine();
System.out.println(inFile.nextLine());
}
inFile.close();


this should at least read and print it right?
im 99% sure the problem is with the String thing, since it has integers on it, but trying it with just hasNext doesn't seem to make a difference, even when it would theoretically read the integers as a string
>>
>>54741421

Post the real code

I have a feeling it's recursive or something
Thread replies: 17
Thread images: 2

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.