Posts

Showing posts with the label numerical-methods

how to save two plots simultaneously in gnuplot

how to save two plots simultaneously in gnuplot Hiii... I havebeen trying to plot two curves simultaneously in a single plot to compare them. ie, by the command: plot "1.txt" w l, "2.txt" w l now I want to save it, but the usual command for saving is: set out "1.txt" but in this case how can I save them together in a same plot? Please click edit under your question and prefix lines of code with 4 spaces. Or select multiple lines of code with the mouse and click the {} formatting button. Welcome to SO. – Mark Setchell Jul 2 at 10:16 edit {} 1 Answer 1 For saving a plot as a file on your disk, you need to setup two things: a terminal and an output . Suppose you have configured your plot interactively in a command-line gnupl...

Recursively calculate the sum of an Array of integers in JavaScript

Recursively calculate the sum of an Array of integers in JavaScript I wanted to write a JavaScript program to compute the sum of an array of integers Recursively . Expected Results Input : [1, 2, 3, 4, 5, 6] Output : 21 I achieved the above results with this code: function calculateSum(array) { if (array instanceof Array){ if (!array.some(isNaN)) { var total = 0; array.forEach(function (value) { total += value; }); return total; } return "Provide an Array with only Numeric Values"; } return "Please provide an Array"; } But I'm looking for a solution that uses Recursion . EDIT : I started doing the above exercise to practice Recursion . I was having a hard time figuring that out. So, That's why I posted this. I'd be glad if you understood. Thanks in advance. What have you tried? What specifically do you need help with? ...