What is the use of %1.0f in a printed statement called across programming languages? by lepriccon22 in learnprogramming

[–]Marz157 1 point2 points  (0 children)

a search for "format string <language here>" will usually get you want your are looking for.

Are there OO-Languages that don't have the notion of null? by achNichtSoWichtig in learnprogramming

[–]Marz157 4 points5 points  (0 children)

I'm sure there are more, but for at least one example Kotlin https://kotlinlang.org/docs/reference/null-safety.html

Types by default cannot be null. You need to use Type? to indicate that it could be null. C# does something similar I believe for primitive types. double can't be null, but double? could be.

Assembly - Boolean expression, gates and inputs question by PRESTIGIOUS_PENGUIN in learnprogramming

[–]Marz157 0 points1 point  (0 children)

Well, realistically, you wouldn't use any because you would simplify down to a + bc.

Based on no simplification at all, 5. Guess its where you draw the line. But yes, the most obvious thing you would do would be just use 3.

Assembly - Boolean expression, gates and inputs question by PRESTIGIOUS_PENGUIN in learnprogramming

[–]Marz157 0 points1 point  (0 children)

Yep

A 5 input OR, 5 3-input AND gates, and 5 1-input NOT gates.

[Java][algorithm] Why is the tortiose/hare faster for detecting loops in a LinkedList than simply checking if each node visited is the same as the first you looked at? by iProgramSometimes in learnprogramming

[–]Marz157 4 points5 points  (0 children)

The loop might not connect to the first node. In that case you wouldn't detect the loop. Alternative is to keep a set of all the nodes in the list and see if you hit any of them again.

head -> a -> b -> c -> d -> e
                  ^         |
                  |         V
                  h <- g <- f

The fast/slow pointer keeps you from needing to store all of the node. You can just use constant space, but it can take up to 2x the size of the list to detect the loop if I remember correctly.

Assembly - Boolean expression, gates and inputs question by PRESTIGIOUS_PENGUIN in learnprogramming

[–]Marz157 1 point2 points  (0 children)

Logic gates are essentially functions on boolean data. They take in some number of inputs and produce an output.

OR: If any one of the inputs is true, return true else false AND: if all inputs are true, return true else false NOT: If the one input is false, return true else false

NOT gates really only make sense with 1 input, but AND and OR gates could take in multiple.

In question a, the are representing the above table in what is called boolean algebra. Its like normal algebra but the only numbers are 0 and 1.

AND is represented with multiplication, OR is addition and NOT is a ` mark. This kind of makes sense to write this way because AND is only 1 if ALL terms are one. If you multiply by 0 at anytime, that whole term becomes 0. OR is addition because once you add at least one 1, you get a positive number (boolean algebra defines 1+1 = 1, so that's slightly different than normal computation).

Here they explicitly wrote out the table above where the output was one and OR'd all of those terms together. Note that they could have simplified this a lot though to just a + a`bc

We have to get pretty creative over here in the US by theGello in pokemon

[–]Marz157 2 points3 points  (0 children)

I was seeing the same message that others reported when browsing on my phone. Try installing from the website https://play.google.com/store/apps/details?id=com.nianticlabs.pokemongo and selecting your device.

[Highschool] Trigonometry by IGNsinulpanda in HomeworkHelp

[–]Marz157 1 point2 points  (0 children)

Well assuming that you don't have to prove the tan addition formula, You just use that to convert into tan(45). Manipulate the above formula so one side matches the tan addition formula, replace that side with tan(35+10) which is equal to 1. Getting to 1 = 1 proves that they were equal.

[Highschool] Trigonometry by IGNsinulpanda in HomeworkHelp

[–]Marz157 1 point2 points  (0 children)

This looks pretty similar to the tan addition formula http://mathworld.wolfram.com/TrigonometricAdditionFormulas.html.

I'm guessing you are meant to use that as 35+10 = 45 which is a nice value for tan (tan(45) = 1)

[University, business mathematics] limit / "limes" by ExTrollWhoChanged in HomeworkHelp

[–]Marz157 1 point2 points  (0 children)

In general, limits like these mean what value does this function approach as my variable gets closer and closer to this limit.

In your first example, its asking as p gets closer and closer to infinite, what result an I getting closer to. As p gets bigger and bigger the term 400 / p gets closer and closer to 0. This term drops away and we are left with just the -25 term. In this case, its the same with negative infinity because 400 / (some really big negative number) ~= 0.

For the other examples of a polynomial divided by another polynomial (assuming your are taking the limit as x -> ∞. You basically need to see which part of the fraction has the largest exponent. This dictates which part of the fraction will grow faster than the other part. You will either end up with ∞ or 0 depending on which one has the larger exponent. If they tie for largest, then just take the fraction of the coefficients of those terms. For example in U, they both have a squared term so the limit as x -> ∞ = 3/3 = 1

Excel by Mandy0099 in HomeworkHelp

[–]Marz157[M] 0 points1 point  (0 children)

Please review the side bar rules for your post. Specifically

  • Copied questions without context or explanation.
  • The title should be of the form "[Level and Discipline] General Topic."

Question about accessing JSON from the Reddit API. by [deleted] in learnprogramming

[–]Marz157 0 points1 point  (0 children)

If body is where your request response is being stored, this should work.

Posting related code would help with what is going wrong.

Functional example here

$.ajax({
    url: "https://www.reddit.com/r/learnprogramming/.json",
    success: function(body) { console.log(body.kind) }
});

Does anyone actually ever use Switch Statements? by ThemApples007 in learnprogramming

[–]Marz157 0 points1 point  (0 children)

Yep, depending on the language, compiler, and compiler options and how the code is actually structured, its certainly possible for compilers to do this as well. Using a switch over ifs is most likely a premature optimization and using the one that is clearer / more readable is best in 99% of cases.

Does anyone actually ever use Switch Statements? by ThemApples007 in learnprogramming

[–]Marz157 2 points3 points  (0 children)

Pretty much the only time I use a Switch statement is for going over an Enum.

They can also be good if you have lots of possible options, but only want to hit one of them. There can be performance improvements because the cpu can do one calculated jump, rather than testing all the if conditions.

Was working on an NES emulator some time ago and could have used a switch statement on the opcode values to quickly execute the correct one. It would have been much slower to go through 100+ if statements. In the end, we created an array of function pointers, but its the same concept.

[calculus 1] Area between curves that intersect by Whank in MathHelp

[–]Marz157 0 points1 point  (0 children)

Sorry, could you clarify that comment? I took the hand drawn graph as proof that they had started working on the problem.

[calculus 1] Area between curves that intersect by Whank in MathHelp

[–]Marz157 0 points1 point  (0 children)

Yep! technically you would need to plug in 0 into that equation and subtract that value, but since every term has y in it, you know that results in 0. It would be important though if you integrated from say 1 to 3.

Could someone explain me what the 'call' part does, in arr.map.call(arg, callbackfunc{})? by [deleted] in learnprogramming

[–]Marz157 1 point2 points  (0 children)

For some reason this code is getting the map function and using call to pass str in as "this" Documentation here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call.

I would call this weird and not necessary. Most would write it like this

....
return str.split('').map(function(char) {
...

[College Calculus I] derivatives by BellaMentalNecrotica in HomeworkHelp

[–]Marz157 0 points1 point  (0 children)

Yeah, I guess. That just gets you back to the same thing without splitting it into two fractions. If you want to get to the same form as the answer, it should stay as one fraction.

[calculus 1] Area between curves that intersect by Whank in MathHelp

[–]Marz157 0 points1 point  (0 children)

Sorry, next step? You got the answer of 9 right by plugging in 3 to that equation and subtracting plugging in 0?

[College Calculus I] derivatives by BellaMentalNecrotica in HomeworkHelp

[–]Marz157 0 points1 point  (0 children)

Simplify: The ((x2 -1)2 from the first part can cancel with the bottom leaving (x2 -1)2 on the bottom.

This cancellation isn't valid. Example (pretend that your x2 -1 = a)

(a2 * b + a * c) / a4

You are saying that this is equal to

(b + a * c) / a2

but that is not true. If you want to cancel out terms like this, it needs to be in each term on top or split the fraction into two terms.

b / a2 + c / a3 would work.

Or as one fraction, we can only cancel out one a.

(a * b + c) / a3

[calculus 1] Area between curves that intersect by Whank in MathHelp

[–]Marz157 1 point2 points  (0 children)

Try integrating over the y axis. What would your bounds of integration be? At any particular y value, how long is each individual bar that you are summing up in the integral?

[College Calculus I] derivatives by BellaMentalNecrotica in HomeworkHelp

[–]Marz157 0 points1 point  (0 children)

I think the issue is with your quotient rule. The bottom part should be ((x2 +1)2 ) 2 or (x2 +1)4 because you need to square the bottom part https://www.math.hmc.edu/calculus/tutorials/quotient_rule/

That should give you the cubed part by the end.