《Programming Wizards!》Functions
Advertisement
“What happened to your face?”
“Accident during a venture.”
“Well,” he poured two drinks and offered one. “I’m glad you’re safe.”
He took a seat across Vick and accepted it. “We need to get the system we found into the database.”
“Sure, we’ll get that in. Do you know what return type it had?”
“Seemed like a new one. I’m not sure if it was a function or method.”
“Speaking of functions,” he laughed, “I taught my class them today.” He was in the mood to meet his friend with a lighthearted story. Avoiding the reminder the day had set in front of them.
“Oh, yeah?” said Amare, feeling curious about his story. Vick never brought up his class, but for some reason it was different this year, and he too wished to forget about this day. “How’d it go?”
“Well, one of the students asked me if you could return a reference to a value. Then, another one asked if you could return a function. What are these kids? Where are they getting their questions from?”
“Did you teach them about delegates?”
“No way,” he shook his head. “Well, kind of, but that would be jumping way ahead.”
“It’ll get them venturing as soon as possible.”
“Yeah, I’ll teach them about classes soon, then send a request to Control.”
An open document on the desk consisted of code. “Is this the code you showed them?”
float Add(float x1, float x2) { return x1 + x2; }
“Yes, just a simple addition function. Takes two float parameters, returns a single float value. Funny thing is, someone asked if you could make a single function that can take any number of parameters instead of a set amount. And, another student answered that you could use an array for that.”
float Add(float[] x) { float value = 0f; foreach (float v in x) { value += v; } return value; }
“And then, I thought I had to explain what a ‘for each loop’ was, but they guessed that it would enumerate through the entire array. Basically a ‘no condition for loop,’ as one called it.”
Advertisement
“Did they use the word ‘enumerate’ to explain it, too?”
“No way,” he shook his head. “If that were the case, they’d be on an expedition right now.”
“Did they understand return types?”
“I explained to them that in this language, the ‘float’ before the name is its return type. Meaning, the function has to return a float. This could be any other data type, but for this, it was a float. And, when ‘return’ is called, the function stops executing and gives the caller the returned value. And then guess what?”
“What?” He leaned in.
“‘Does the return always need to be at the end?’ he said.”
“Who said?”
He pointed two fingers above his eyes. “The kid with the sharp brows.”
“What kid?”
“This kid,” he said and opened a document that listed pictures of the students alongside their names. “Roy.”
“Roy, what a conscientious kid!”
float AddBelowFive(float[] x) { float value = 0f; foreach (float v in x) { value += v; if (value > 5f) { return -1f; } } return value; }
“So, I explained to them that there can be as many returns in the function, but the function must conclude by returning a float.” He rubbed his eyes to clean the escaping tears, both from the unexpected hilarity and sharp-wittedness. “They actually asked,” he continued, “if you could pass a function as a parameter because the square brackets on the array made it look like a function. They thought if an array can be passed in, maybe a function can be too.”
His spit went flying with his laughter. “A red herring landed them straight into advanced techniques? What did you tell them?“
“I explained to them that a function is like a class. Although, they had no idea what a class was. So, I explained to them that when I write ‘Console.WriteLine,’ the ‘Console’ part is referencing a class. The Console class contains functions within it. One of them is ‘WriteLine.’ I use that function to print text onto the screen. A function—and I probably jumped too ahead—is like a class. By putting parentheses at the end of a function’s name, you are calling it to be executed. It’s like writing the ‘WriteLine,’ but without a name of its own.”
Advertisement
“Did they figure out you can reference functions?”
He smiled as if he were caught. “Yes, yes they did. I told them that a function can be treated like any other variable. That the ‘type’ of a function is made of its return type and parameters. I quickly wrote an example for them.”
float Add(float x1, float x2) { return x1 + x2; } Func add2 = Add;
“I told them that in this language, a ‘Func’ is a type. I didn’t call it a delegate to not convolute the terminology, but yes, a ‘Func’ is a delegate which is a type. We give this Func three parameters, and the last parameter is the return type, whereas all the parameters before that are the parameters for the function. Hence, ‘float, float, float.’ Now, ‘add2’ can be executed like the ‘Add’ function by using parentheses.”
“Observant students!”
“They sure are.” He stood up and they both caught a glimpse of the date upon the desk as its screen went dark. “Anyway, lunch?”
A burrito filled with all sorts of vegetables, and on the opposite, a single sandwich. “Once we figure out where the system leads us, we can finally figure out who the caller is.” He sighed. “How long has it been?”
“Feels like a much longer time, but today marks four years.”
“Remember Dorothy?”
“Yeah, what about her?”
“Right,” he said and began playing with the onions inside the wrap.
Vick said nothing, not wanting to intrude on whatever it was Amare was feeling. He sniffed, and Vick saw the gleam in his eyes and how his thick brows frowned as he darted his head from one end of the cafeteria to the other. Held back those tears from flowing in the middle of the crowd. A dozen seconds passed and he was inclined to break the tension. “You—”
“I—”
“Loved—”
“Loved—”
“Her.”
“Her.”
They looked at each other and faintly smiled simultaneously, just as they had said those words. And, Amare turned away. “What made you think of her?”
“I saw a hand reach out to me through the hole in the sky.”
“Hole in the sky?”
“Yes,” he pointed up. “Above the clouds, from the stars.”
“In the gyroplane? When did it happen?”
“Yesterday, I went up there alone. I tried to reach for her but Rorohiko stopped me. I crashed onto the floor and had glass splinters fly into my face. Then, her light called out to me and I was able to pull myself up.” He paused to look up at the bright lights that were fifteen meters high. “The Cleaner-Lower,” he said. “She made it shine for me.”
The thought of a cleaning robot being his savior made Vick chuckle. “You’re a hopeless romantic.” Amare stared at the lights with a miserable smile, either taking his words seriously or not listening. “I’m kidding,” he said quietly. “Well, now I know what you meant by ‘accident,’” he said louder, trying to divert the situation from prolonged awkwardness.
“You’re eating that sandwich again.”
“Yes,” he said, caught off-guard by the sudden change in tone. “It’s quite delicious.”
“Don’t you ever get bored of it?”
“No. I mean, why change something that’s not broken?”
“To try something new, find something better.”
“I guess, but…”
“But?”
“I’m already eating this.”
“Next time!” he said a bit too loudly and it washed away every wrinkle of sadness from his face. “Next time I’ll prepare a tasty meal for you. How does that sound?”
“Yeah, yeah,” he said softly. “That sounds wonderful.”
Advertisement
- In Serial170 Chapters
Psycho X Psychic
Teren Hark — Quiet and ordinary at school. Passive and nothing noteworthy about him. However, one of his classmates thinks otherwise.Iesa Hun — Quiet but extraordinary. Aggressive when provoked. On top of the school’s hierarchy because of her brains and beauty. Recently, she learned the secret about Teren Hark.He’s a psychopath who had a rich history of murder, massacre, and other atrocities.But she has her fair share of secrets as well — she’s a psychic who can read other people’s thoughts, except, of course, the psychopath himself.Welcome to Mershen High where these two superhumans collide as they slowly learn each other’s pasts and meet the world’s hidden supernatural together while still trying to be proper students.
8 2369 - In Serial24 Chapters
Reverie
Natalin thought that being a champion of the gods was supposed to make things easier. It turns out, life isn’t that simple. For centuries, the four gods that rule the land have each chosen a hero, a mage-warrior to act as eyes and hands in the world. Gifted with their Divine’s blessing, these Ascended and their successors have worked for centuries to ensure the land stays at peace. As the new Tideborn, the disciple of the sea god Efren, Natalin is expected to follow in their footsteps. Her counterpart Takio finds himself in the same boat, tasked with keeping his volcano goddess patron in check. The demands placed on them are immense, but together with their nations, they’ve managed to keep the peace. Until the crops and grasslands begin failing, sending Takio’s mountainous nomads careening towards war. Natalin’s shores fall under siege, destroying the seabound trade routes that keep their nations flourishing. When the very safety of the four champions is threatened by the growing chaos, Natalin and Takio realize the truth - their Divine favor won’t protect them. And there’s more at play in their ‘peaceful’ world than they’d thought. Cover art by Rin! Check out her work!
8 262 - In Serial84 Chapters
Paradox Fighters
Note: Updated WEEKLY on Thursdays. Contains graphic violence and mild language. Also available on Fanfiction.net and Archive Of Our Own. "The plot idea itself is hard to top in terms of simply and rarely performed premise (At least within the confines of RoyalRoad material)." -FrustratedEgo, The Group (RRL) "I'm afraid to read this but I'm so, so happy it exists." -Lekosis, Archive of our Own "Holy this, this was fucking amazing ... Really compelling at times, wow, can't wait to see what happens in the next part." -Princess Unikitty, Fanfiction.net "You've successfully found that perfect tone where you can have such outrageous and insane things like xenomorphs fighting witches and bondage wearing warrior women on an Illuminati space ship traveling through the multiverse and still have me care about the characters in your story." -Lucantius, Fanfiction.net When a Great Old One is mortally wounded, he summons warriors from a multitude of worlds to do battle with each other so their anger will strengthen him. We follow Holly Short, a character from the Artemis Fowl universe, as the tournament begins. But Carcosa has many secrets in store... An epic crossover with fictional characters from a wide variety of mediums- from classic and modern literature, B-movies and blockbusters, cartoons from both east and west, and a plethora of video games- all thrown into nail-biting combat (and the occasional hijinks). Comment, Critique, Reviews welcome and EXTREMELY appreciated!
8 255 - In Serial10 Chapters
Can a Lich Cry
Update every 1-2 weeks. Well, I say that, but I usually write during the weekdays and chill in the weekends. Should be the other way around, but writing helps me destress with schoolwork. The cover is a make-shift drawing I made some time ago. The Seven Kingdoms moved at the will of their prophets. They were the voices of their gods, and the deities wanted blood. After being caught in the crossfire, a young man named Sura died among the endless corpses. However, he inherited the Curse, and the Curse did not allow him to rest. When Titus conquered the Seven Kingdoms, he was still there. When mages became the new prophets, he was still there. Centuries later, the lich had faded into the unknown as the aide of Fia, the bastard mage and the only descendant of Titus. A dead man did not have anything to protect, so what did he fight for? For the game was not over, and it was still his to lose.
8 62 - In Serial45 Chapters
Duology: Light
Matthew Baronia is a prodigy among his peers, a young man recognized by his kingdom. As a fighter, a knight to be specific, Matthew is expected to take on the monsters that trouble the surrounding cities of his kingdom. Joined by his friends, Brian the dragoon who acts before he thinks, Eric the Cleric who loves to chat, Jessica the hotheaded mage, and Adriana the sarcastic Rogue, Matthew must escort a group of archeologists. Their job seems simple, but danger lurks, and a scheme is being devised while the team is pre-occupied. All the while, Matthew must deal with the woes of a team leader.
8 81 - In Serial13 Chapters
乃ㄥㄖㄖᗪㄚ 乇ᐯㄖㄥㄩㄒ丨ㄖ幾丂 || ⓇⓌⒷⓎ
|{Vampire! RWBY Harem! x Kamen Rider! Female Reader!}|!!Edit belongs to me, but the renders aren't mine so credits go to the original owners!!"Welcome to a World of Bloody Evolution."The world is always in the way of harm. And that is why the world needs a great defender against the darkness that is upon them.But... could there be something much darker under every solution that people make? Not only do legends scatter but also the ultimate nightmare that's bound to taint Remnant in its filthy blood.You, [Y/N] [L/N], were the last Kamen Rider to survive in the Kamen Rider War. You barely won against Odin, but you managed to win against him, striking the Phoenix rider with your Final Vent. Although it seemed like a happy ending as you were granted with one wish of any kind, you realized that justice, hope, and peace were forever gone.Justice had not been served and the hope of everyone making it out alive had slipped away.You did what you thought was right, and that was wishing for everything to be back to normal in Japan. No more monsters. No Mirror World. Japan was back to its normality. The Kamen Riders that you faced during the war had all been resurrected and returned to their lives. Their memories of Kamen Riders and you had been erased. Everything and everyone went back to normalcy.There was nothing else left for you in Japan, and so you decided to travel around the world. You took all of your belongings with you and left the past behind.You chose Vale, the eastern end of the newly found continent named Sanus, and began your journey. All you knew about the kingdom was that it was filled with an arsenal of airships and weapons along with technological innovations that were far more advanced than your homeland.But what you didn't know is that you were being welcomed into another world of bloody evolutions.
8 64

