Why languages do not allow multiple return values? [closed] - return-value

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In languages like C which supports pointer operation, you can easily get multiple values from a procedure. But in languages like Java, it is a pain if you actually need to get multiple return values. (Using an object to wrap multiple values is bad)
In my experience, allowing multiple values returned can help improve software engineering--more flexible to organise procedure invocation, etc. But why there are so many languages that do no allow returning multiple values? I am interested to know the reasons. Thank you very much.

Could be because many of the designers of these languages have strong math backgrounds and in math a function can have multiple input parameters but (almost always) only a single output value.
Also, it keeps code understandable and standardized to some extent.

Related

How to name my averaging technique? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Suppose, I have a list of values {4, 10, 3, 6, 7, 15, 11}. The average of this number list is avg=8. Now I will select only those elements > avg, which are {10, 11, 15}. Now I am doing average again and selecting the elements bigger than their average. I believe this a helpful technique to get the top rated values from a list, I am not sure about the naming of this averaging technique. Can anybody help me with some name of this method?
Thanks in advance
How about using Averoveraging?
I'm not sure what your code looks like, but I'd imagine on one pass you are returning elements higher than the average? So I would name that method ElementsGreaterThanAverage.
If you're only always doing two passes, you could call it TopQuarterByAveraging or something.
You're computing the mean, then showing everything over it. Hence OverMean.

How many Distinct n variable boolean functions are there? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Since there are n variables wouldn't there be 2^n boolean functions?
For an n-ary boolean function, there are 2^n possible boolean inputs. Each input can generate
either "true" or "false" as the output. How many different ways can you arrange the 2^n true vs. false outputs?
If there are p possibilities for choice 1 and q possibilities for choice 2 then there are a total of p*q different ways of doing both.
It is trivial that this can be extended to n choices.
http://en.wikipedia.org/wiki/Rule_of_product
So, yeah, there would be 2^n boolean functions (as for each choice there are two alternatives).

Numerical Methods tutorials/books/videos for non math knowers [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm currently attending the first year of college at Computer Science. I'm having great problems with something named Numerical Methods because I lack at mathematics. I don't have a basis for math concepts.
Could any of you please tell me a good book, tutorial site or videos of Numerical Methods for people that don't have a clear basic knowledge of mathematics?
I tried looking for something like "Numerical Methods for Dummies", but I didn't find anything equivalent.
For good reference books on numerical methods, you can check out the answers to the question What is the best book on numerical methods?
Bear in mind that numerical methods are a subfield of Maths. Thus you do need a clear basic knowledge of mathematics and you probably need to look for other books (not Numerical Methods ones) to fill your knowledge gaps.
Try Numerical Methods for Scientists and Engineers
Try sniffing around the internet for course notes (lecture notes) from other universities, especially for first year/second year engineering mathematics (for a general grounding) and numerical methods after that.
My university had very good lecture notes, but I can't distribute them. Other universities are more liberal.
You may also want to check out MIT OpenCourseWare, which contains lecture notes and course materials from the Massachusetts Institute of Technology. Some of the lecturers at MIT literally wrote the book on their respective field, so you can't go wrong with anything you find there.
Links to interesting courses on MIT OCW:
18.330 Introduction to Numerical Analysis
6.042J Mathematics for Computer Science
I do not know if this suits you... but you can try this:
http://apps.nrbook.com/c/index.html - Numerical Recipes ( http://www.nr.com/ )

How do I write a generic function that takes a Number or some alphabets and display that in 7- bit segment display.? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to write a Digital Clock application in which I have a 7- bit segment display. I want to write a generic code for displaying all the input. I have a CGPath in which I have 1 line for each segment.
Now, how would I write a generic function for the above description?
Any help with some logic or code will be appreciated.
Thanks
Simplest would be a look-up table. You could do it with ten bytes. Assign one bit in the bytes to each segment. Pre-load the table with the hex values necessary to set the bits. Index the table with your digit 0-9. If you want to have additional combinations of segments then make the table larger -- typically these are set up to display an additional 6 "characters" (eg, A, b, C, d, E, and F), making the table conveniently 16 long.
But, for extra credit, do it with NAND gates.

Loading a file into MATLAB as it is? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm working on a telecommunications device simulator on MATLAB. I'm going to encode some digital data, modulate it, add some noise and attempt to demodulate it, see at what noise levels my data cannot be recovered anymore.
My problem is, I don't know how to import some crazy file to my workspace. It's not going to be txt or anything, just some file. How can I make MATLAB read the file in binary format or whatever it is called?
Try questions regarding to work with binary data in matlab
Working on Binary Data in Matlab
Read and write from/to a binary file in Matlab
Can you be more specific ??? Instead of specifying whatever format you could actually look at the extension and specify the extension.If it is a video then you can read it with mmreader(),if it is an image then you read it with imread().So please specify the extension of the file which you want to load into MATLAB.
H2H
-Harsha
It turns out I was using the right function with wrong parameters all along. I opened the file I wanted to open with fopen('filename') and used the number that function outputs in A=fread(thenumber). That returned an array of each and every byte in the file by their decimal values. I'm sure I'll be able to use this data for my project.
Thanks to everybody for their help!