• Breaking News

    Monday, March 1, 2021

    How does a compiler handles function calls in an expression? Ask Programming

    How does a compiler handles function calls in an expression? Ask Programming


    How does a compiler handles function calls in an expression?

    Posted: 01 Mar 2021 04:06 PM PST

    Hello everyone! So I was thinking... Let's say you have a random expression such as this:

    3 * x + (3 + (2+ 1)) / (func(y, 3) * (3+y)) 

    where x and y are variables and func() is a function call. Now, I suppose lots registers will be busy holding numbers while this is getting evaluated, and that shouldn't be a problem if there's no function call in the expression; However, when a function gets called midway trough the computation, how do you keep track of all the values in the busy registers? I mean, func could potentially alter the value of some of the already busy registers, messing up the whole evaluation. How does it work? (I hope I was at least somewhat clear about this) :)

    submitted by /u/accipicchia092
    [link] [comments]

    I still don't understand the "prefer composition over inheritance" thing (OOP)

    Posted: 01 Mar 2021 04:09 AM PST

    There are tons of Stackoverflow questions using the same two examples

    A dog IS AN animal A car HAS AN engine 

    The first should use inheritance, because the relationship is IS-A

    The second should use composition, because the relationship us HAS-A

    So when am I actually supposed to favor composition over inheritance? This SO question has examples like an Employee class with a Person in it, but surely an employee IS-A person?

    Anyone got a good example of using the principle of composition over inheritance that doesn't break the IS-A/HAS-A rule?

    EDIT: thanks for all your responses! This thread was way more intuitive than all the SO answers I've come across.

    submitted by /u/Open-Self
    [link] [comments]

    Is it bad if I look things up?

    Posted: 01 Mar 2021 12:27 PM PST

    So I call myself a 'JS and PHP developer' , as I've programmed for countless hours in those languages

    But I've noticed that despite my 3 year experience with both of them, I look up a lot of things.
    I know the basic functions, I know and understand data types, arrays, loops, classes, Object-Oriented Programming and stuff, but I still don't know some things / functions by heart and look them up in the documentation.

    Do 'good' programmers know things by heart? Or is it ok if I look things up?

    submitted by /u/-JVT038-
    [link] [comments]

    What are the differences between these 2 variables?? (React Js)

    Posted: 01 Mar 2021 04:07 PM PST

    pls help me identify 2 unknown error in python(line 40 and line 30)

    Posted: 01 Mar 2021 03:07 PM PST

    import random def computer_guess(x): low = 1 high = x feedback = "" 

    guess = random.randit(low, high) #line30

     while feedback != "C": feedback = int(input(f"Is {guess} too high(H), too low(L), OR CORRECT(C)?")) if feedback == "H": high = guess - 1 elif feedback == "L": low = guess + 1 else: print(f"Yay! The computer guessed your number, {guess}, correctly!") 

    computer_guess(10) #line40

    input() 

    Traceback (most recent call last):

    File "c:\Users\91844\Desktop\project1-python\guessthennumber.py", line 40, in <module>

    computer_guess(10)

    File "c:\Users\91844\Desktop\project1-python\guessthennumber.py", line 30, in computer_guess

    guess = random.radiant(low, high)

    AttributeError: module 'random' has no attribute 'radiant'

    submitted by /u/Amaanullah1102
    [link] [comments]

    Polar Arrays

    Posted: 01 Mar 2021 09:03 PM PST

    Hello! Just recently learned how to program and I got in touch with NumPy arrays in Python. They seem to have a rectangular structure.

    Is there a way to convert this rectangular grid array into another form (i.e. storing data points in a polar array if there exists such a thing)? Are there libraries that specifically cater to that kind of feature?

    Thanks!

    submitted by /u/Tough-Computer-6956
    [link] [comments]

    How do you pronounce # in your head?

    Posted: 01 Mar 2021 08:14 PM PST

    If you saw #include... would you read it in your head as "hashtag include"? Or "pound sign include"?

    For bonus points what's your approximate age? Were your formative years before or after instagram hashtags/twitter hashtags became mainstream?

    submitted by /u/survivalking4
    [link] [comments]

    Presenting SQL Categories query

    Posted: 01 Mar 2021 02:43 PM PST

    I'm following the advice here to handle categories/sub-categories: http://www.sqllessons.com/categories.html

    I've taken the first approach described, root and down1-3, and the query is working well.

    How would you approach displaying these categories in <ul> and <li> tags? Any advice?

    Made a start and got it semi-working but I don't think I'm doing it efficiently.

    I'm using PHP but pseudo code or a high level description of how others would approach this would be great!

    submitted by /u/AnusPicsPlease
    [link] [comments]

    How to call Class in one module from an imported module in android

    Posted: 01 Mar 2021 10:54 AM PST

    I have two modules in my project app and app-detection which I imported into my current project and it compiles perfectly. The dependency is as follows:

    implementation project(path: ':app-detection',configuration: 'default') 

    This was imported in my app module

    However when I try to call a class from the app-detection module into my app module which I'm dependent on it doesn't recognize it or the import statement. How do I go about calling a class from the other module in my project? For example as shown below there is a DetectorActivity class in my app-detection module that I would like to call in my app module, but it doesn't recognize it.

    @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.other: Intent intent=new Intent(BindGlassActivity.this,QRCodeActivity.class); startActivity(intent); finish(); case R.id.translationButton: Intent secondIntent = new Intent(BindGlassActivity.this,DetectorActivity.class); startActivity(secondIntent); finish(); break; default: break; } } 
    submitted by /u/kharlm12
    [link] [comments]

    What does a Hello World program actually do?

    Posted: 01 Mar 2021 03:46 PM PST

    So, I've written Hello World programs countless times in countless languages, on many PCs, on different OSs, everything. Here's a standard hello world in C++:

    #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; } 

    So my question is: what does std::cout (or print(), or System.out.println(), etc.) actually do? I never wrote any code to render text, to create a window that shows my text, to talk to my IDE to show text in the built-in terminal, etc.

    So how does a print statement talk to the console, decide whether it should create a new window or show the output in the terminal that I already have open? Is all that code bundled in iostream/JVM/Python interpreter? Is it something handled by the OS, something else entirely?

    submitted by /u/yonatan8070
    [link] [comments]

    getting unkown error in my python code below in line 8

    Posted: 01 Mar 2021 03:29 PM PST

    import random def play(): user = input("What's your choice? 'R' for rock, 'P' for paper, 'S' for scissor \n") computer = random.choice(["R", 'P', 'S']) if user == computer: 

    return 'It\'s a tie' #line 8

    if is_win(user, computer): return 'You won!' return "You lost!" def is_win(player, opponent): if (player == "R" and opponent == "S") or (player == "P" and opponent == "R") or (player == "S" and opponent == "P"): return True 

    PS C:\Users\91844\Desktop\project1-python> & C:/Users/91844/AppData/Local/Programs/Python/Python39/python.exe c:/Users/91844/Desktop/project1-python/stone-paper-scissor.py

    File "c:\Users\91844\Desktop\project1-python\stone-paper-scissor.py", line 8

    return 'It\'s a tie'

    ^

    SyntaxError: 'return' outside function

    submitted by /u/Amaanullah1102
    [link] [comments]

    Some hints on creating a program linked to a GIMP plugin ?

    Posted: 01 Mar 2021 02:58 PM PST

    Hey guys !

    The fact is that my knowledges on programming are basically none, I just started a week ago to code on python (in order to do a wider range of things out of it). In fact I just applied to one of my Art school program named "Modular Studio", it's basically searching for new art forms through new technologies, such as programming for instance. The fact is that we are not really taught anything consistent and so when I asked about doing a program that could process images (photographs) with as a result images that have been filtered by zones, they said they couldn't really help me at all.

    Sooo I know it's not like I'd like you guys to do the whole program for me ('cause you all have lives) but I'm looking more into some hints to start coding this quickly with what you could call a (really) limited amount of knowledge. If you guys could help me on that I would just be so psyched.

    The thing is, to put things more clearly, I'd like this program to be able first to import an image from my computer, then to randomly select areas of the image thanks to GIMP tools (selection squared, per color, per zones sith magic wand, etc...) and then to apply to these randoms selections random filters that are from the GMIC plugin (basically a plugin for GIMP that has sooooo much new functions in it), and only then to give me as an output the transformed image.

    The fact is I want to devellop a whole new practice as a (future) artist, questionning the way we perceive and interpret the world around us by putting it in perspective with alternative ways of seeing things (I'm also working on a prothesis that includes a camera module for raspbery pi that process the images it records into Fourier Transforms Images, but by analyzing contrasts, kind of like the FFT but still not really like it), and one of this way is through modern technology. I'm convinced that the tools we developp today will surely become important mediums in the future of Art, and so it goes for stuff like programming or engineering. The fact is that if you don't get bored about what I say, maybe pay a visit to r/ContemporaryArt and maybe you'll be pleased !

    Thanks to those who will take the time to read all the way through and those who will answer my need for help !

    submitted by /u/OWMshindeiru
    [link] [comments]

    Basic project I need directions with! :)

    Posted: 01 Mar 2021 02:13 PM PST

    Hey everyone!

    I got a small project i want to realise, but i don't know if its possible, since flash is not supported no more. I also gotta say it's been a while since I stopped programming and all, so I want to keep it as simple as possible

    My project: I want to play an old online games i've played younger, in fact I wanna create a private server for people to come and play with me.

    My problems: Not only the original website is closed since 2016, But now adobe flash is not supported anymore in web browsers. Also as I said, I'm very a beginner when it comes to programming, I know a lot of things but ain't wrote a line of code in years.

    Before Adobe Flash stopped being supported, a lot of "private servers" of this game opened left and right on the internet. Is was cool playing with old players of the original website who just wanted to play again on their childhood favorite game. But then 2020 came, and every single one of theses server closed due to flash. Which finally leads to my questions:

    • Is it possible to find the old .swf files and everything, then download them, like via wayback machine or some other archives website ?
    • Can we still play multiplayer on a flash game ?
    • I guess every private servers had to code their own database multiplayers thing, right ?
    • Could I find the files and do a .exe of the games for people to download it ?
    • What would be the proper steps for me to look into to realize this project

    So to put it simple, I just wanna play an old online games that is now closed. Since a lot of private servers used to be active, I guess programming their own multiplayer connection wasn't that though after all, if the game files are still somewhere. I'm capable of making a clean wix website, paying and hosting a server for ppl to play on, probably capable of getting the old files if someone direct me in the good direction. The only part i'm really clueless is how to get the old .swf files and get the multiplayer going

    Sorry if its chaotic, i'm pretty clueless about where to start, thanks for reading tho! :)

    submitted by /u/MyBoiJams
    [link] [comments]

    How can I achieve this layout?

    Posted: 01 Mar 2021 12:42 PM PST

    https://imgur.com/a/7Wql3ij

    i have a livejournal account and was trying to make a blog post where i have this sort of layout.

    two titles, two images, two blocks of text separated by two columns, centered in the page. how could i achieve this effect via html/css?

    i have forgotten virtually everything i knew about basic html since school so i would like to ask someone to please help me with this if they could. sadly i don't have any friends to help me with this so i'm asking here.

    i hope this is the right subreddit to ask such a question, i apologize and will take it down if it's not. thank you so much;;

    submitted by /u/lvl505
    [link] [comments]

    Java vs Python for Vector Graphics and SVG and DXF file types.

    Posted: 01 Mar 2021 07:04 AM PST

    I'm interested in trying to develop some CNC GCODE generating software. Rough features include a GUI with vector image visualization, import/export of the above file types and maybe some vector editing. Basically a desire to learn about what's under the hood of CNC/CAD software.

    So I'm wondering which language would have better libraries for such an application. To be honest it's been a while since I've programmed and I want to pick a general language back up but I figured I'd start with the one suited for near future projects.

    submitted by /u/TRG903
    [link] [comments]

    JavaScript code (code.org)

    Posted: 01 Mar 2021 09:11 AM PST

    hey I need help with creating a code for a calculator. I have created the design(as in the app picture) for it. I jus need the code to follow with the basic calculator. I need the app to have a function, lists, parameter, and An algorithm (that includes sequencing, selection, and iteration). This program is on code.org and has to be in JavaScript(that's the language code.org uses). https://studio.code.org/projects/applab/dzSu8DgHanrKs5xFgdwEGr_zrX7laATlGNECBzlKMug

    submitted by /u/Ok_Composer_9458
    [link] [comments]

    Visual Studio 2019 not repainting window. Completely unusable.

    Posted: 01 Mar 2021 04:58 AM PST

    [Solved] Hello, I have a problem with visual studio 2019 not repainting it's window. I create a WPF project and try to view form's events. Properties toolbar has text blacked out so I cannot even see what do I click on. I cannot use Visual Studio at all.

    Version of VS: Visual Studio Community 16.8.1. Later updated to latest 16.8.6.

    I have Asus Tuf gaming A15 with Nvidia 1050 Ti mobile. I was googling a bit and found out that some gaming laptops do this. I have Windows 10 Pro.

    When I open VS2019 and go to Tools -> Options -> General i see three checkboxes there:

    Automatically adjust visual experience based on client performance.

    Enable rich client visual experience

    Use hardware graphic acceleration if available.

    I tried all combinations of checked/unchecked and didn't help.

    I have updated to latest Nvidia driver 461.72. Updated Windows 10, laptop firmware. Retried all combinations of VS checkboxes. Didn't help.

    Has anyone encountered this problem? How did you solve it? I have an idea to run VS inside VM as last resort.

    Solution: I was changing settings in VS -> Tools -> Options -> General

    unchecked: Automatically adjust visual experience based on client performance.

    checked: Enable rich client visual experience

    checked: Use hardware graphic acceleration if available.

    This didn't solve the problem, I had also to change VS Color Theme to Dark or any other theme in VS -> Tools -> Options -> General, and then VS window started to repaint properly.

    NVIDIA Control Center Visual Studio Community 2019 settings restored to default

    Start Menu -> Settings -> Display -> Graphics settings -> Graphics performance preference -> Browse to devenv.exe and set it to High performance. Not sure if this is needed to solve the problem.

    submitted by /u/StaticConstString
    [link] [comments]

    What output is produced?

    Posted: 01 Mar 2021 11:42 AM PST

    include <stdio.h>

    int main () (int x, i = 2, j = 10, final = 1; while (i <= j * 2) { i = j - 3; for (x = j; x >= 0; x = x - 2) Printf("x is Id j is Id i is Id\n",x, j, i); J--+; i++; final = final + (i - 1) * (j-2); ) //for Printf("New i = Id", i); i=i + 3; I//while Printf("\nFinal Output: ,d\n", final); return 0; }//main

    submitted by /u/hyper-lemon17
    [link] [comments]

    Diagonal difference

    Posted: 01 Mar 2021 06:27 AM PST

    How does this work?

    If it was a square matrix then seems straight forward

    First diagonal would be all array[i][I]

    Second one I think array[i][maxRow - i - 1]

    But I think this just assumes it's a square matrix. The first example shows a non square matrix and I don't see how you can account for that

    submitted by /u/ShinigamiNeo
    [link] [comments]

    Can someone please point me in the right direction with building a form.

    Posted: 01 Mar 2021 02:36 AM PST

    So I think in essence what I am trying to build is a form to submit values.

    At work we have a team of people doing a very repetitive task upwards of 500 times a day (each). I want to build a form that allows them to speed this process up. Without going into un-needed detail, think Quality checks on products.

    I want to build a form that looks something like this (with some different values in the boxes.. https://imgur.com/a/IoHvzBC

    I want the user to be able to select one or multiple boxes hit submit and have the data write to a data table.

    I am pretty low level at coding, but get by with google and trial and error (lots of trial and error). With this one, I really am a bit lost on where to start looking.

    I would preferably like this to be used on a web browser hosted locally.

    Thanks in advance for any help.

    submitted by /u/4ndr01d5
    [link] [comments]

    unable to identify what is syntax error in python line 15

    Posted: 01 Mar 2021 05:55 AM PST

    import random def Computer_guess(x): low = 1 high = x feedback = "" while feedback != "C": if low != high: guess = random.radiant(low, high) else: guess = low feedback = input(f"Is {guess} too high(H), too low(L), OR CORRECT(C)?") if feedback == "H": high = guess - 1 else feedback == "L": low = guess + 1 elif: print(f"Yay! The computer guessed your number, {guess}, correctly!") Computer_guess(15) 
    submitted by /u/Amaanullah1102
    [link] [comments]

    when i m running my below python program i m getting this unknown error pls can anybody help me..

    Posted: 01 Mar 2021 05:42 AM PST

    when i m running my below python program i m getting this unknown error pls can anybody help me..(edited)

    import random def guess(x): random_number = random.randint(1,x) guess = 0 while guess != random_number: guess = input(f'Guess a number between 1 and {x}:') if guess < random_number: print("Sorry, guess again. Too low") elif guess > random_number: print("Sorry, guess again. Too high.") else: print(f"Yay, congrats. You have guessed the number {random_number} correctly") print(guess) guess(10) input() 

    (running program in terminal below)

    Guess a number between 1 and 10:6 Traceback (most recent call last): File "c:\Users\91844\Desktop\project1-python\guesstheno.py", line 19, in <module> guess(10) File "c:\Users\91844\Desktop\project1-python\guesstheno.py", line 8, in guess if guess < random_number: TypeError: '<' not supported between instances of 'str' and 'int' 
    submitted by /u/Amaanullah1102
    [link] [comments]

    Problem with URLs || Local Ghost --> Gatsby --> Netlify

    Posted: 01 Mar 2021 01:21 AM PST

    I have a problem. I've searched everywhere, and I'm either terrible at searching, or this is so simple that nobody else has searched for it.

    I am using Ghost CMS locally (localhost:2368)

    I am using Gatsby local (localhost:9000)

    I am pushing to Netlify.

    I write content in ghost, build it with gatsby and deploy it to Netlify.

    However, the blog post image URLs are stuck as localhost:2368 on the live version of my website.

    The images are loading locally on my machine but not anywhere else. I know that's probably to do with the URL.

    I've spent several hours on this, and I'm finding it difficult to get my head around.

    I managed to create a Cloudinary account, and my painstaking plan is to manually change all of the image URLs to Cloudinary URLs, which doesn't work. (not sure if I'm changing them in the wrong place, I tried editing in Gatsby and Ghost, but they revert to localhost URL).

    Can you help me with a solution, please?

    submitted by /u/WritingWordMan
    [link] [comments]

    No comments:

    Post a Comment