CalcNoteHelp icon indicating copy to clipboard operation
CalcNoteHelp copied to clipboard

Feature Request: Ability to freely edit user defined functions / skip tests

Open Wakadaisho opened this issue 1 year ago • 1 comments

I'm trying to write a summation function that takes 3 arguments, p1 and p2 for the limits and p3 for the function to compute. I cannot get past the testing part of the definition because it only accepts numbers but I want to pass a function for p3.

Is this something that you can work on? I know there may be other tools more useful in this case but I think this would be a good feature to have.

Wakadaisho avatar Oct 15 '24 06:10 Wakadaisho

It wouldn't work even if you could bypass the test. For some reason he has gone out of his way to break parameters that aren't numbers. Try wrapping your code in a try/catch where the catch always returns a number to pass the test and see.

You can literally do(well, function name is too long)

function arbitraryLimitation(p1) {
try {

function multiply(val, mul) { return val * mul; }
function inner(val) { return multiply(val, 3); }
function outer(fn, val) { return fn(val); }

      if (p1 == "ten")
         return 10;
      
      if (p1 == 9)
         return 9;

      if (p1 == 8)
      {   var parsesJustFine = "F";
          return (parseInt(parsesJustFine, 16) + 1) / 2;
      }

      if (p1 == 7)
      {   var errorsJustFine = "E";
          return(parseInt(errorsJustFine, 16) / 2).toMalarkey();
      }

      if (p1 == 1337)
          return outer(inner, 1337);

   }

   catch(e) {
      return e;
   }

return 0;

}

You can't input anything except numbers on the test screen, but it will straight up not evaluate non-numeric parameters in the calculator interface. Passing functions and strings work fine internally, as you can test with the above.

immateria avatar Aug 30 '25 07:08 immateria