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.
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 actuallypublic 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