Can you create functions out of thin air? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 3

Can you create functions out of thin air?

So let me rephrase my question.. I mean, is it possible to open a blank page and create variables and functions and the text editor acts accordingly to whatever random stuff you create or is there a set of words we have to use to get the text editor to behave the way we want? Sorry if this is confusing.. Iā€™m just thinking about the example, print(ā€œhello world!) What if I wanted to use display(ā€œhello world!) ?? Would I get a reaction from the computer or is there no way to do this?

29th Aug 2018, 5:23 PM
Argenis De La Rosa
Argenis De La Rosa - avatar
5 Respostas
+ 5
Not sure about other languages, but in python that's totally possible. You can redefine everything to your liking. You just need to create a function display(string) and define what it does (print the string to the screen). I don't necessarily see why you would want to do that, but it's possible. In other languages like C++, you can use macros in order to customize the syntax of the language. Technically it should be possible to replace cout << x with something like display x
29th Aug 2018, 6:06 PM
Anna
Anna - avatar
29th Aug 2018, 6:27 PM
Sebastian KeƟler
Sebastian KeƟler - avatar
+ 1
In Python you can safe your costomized Functions and call them as Modules: https://www.sololearn.com/learn/Python/2438/?ref=app
29th Aug 2018, 7:01 PM
Sebastian KeƟler
Sebastian KeƟler - avatar
+ 1
Yes you can do that in Python .You have to display("hello world") and then define the function (print display)
1st Sep 2018, 6:11 PM
Rahul Parande
Rahul Parande - avatar
0
ok, your first link made sense sebastian. I suppose by doing somebting like print = cout you can modify the code to your liking! now, is there a text editor that gives me the fliexibility to set custom code or do I have to set it for each project? thanks for the help !
29th Aug 2018, 6:54 PM
Argenis De La Rosa
Argenis De La Rosa - avatar