.append or .after defined as a variable?

So I'm trying to figure out the best way to get this to work. I have a long list of code that's pulling off of a JSON database, and I'm trying to streamline it. I've created the following function: var insertData = function(formattedData, originalDa...
more »

2017-05-20 20:05 (2) Answers

Is it correct using stack in my implementation?

#include <iostream> / File: int-stack.h / #include <cstdlib> using namespace std; const int BUFFER SIZE = 100; class int stack { private: int data[BUFFER SIZE]; // Use an array to store data int top_index; // Start from 0; -1 when empty p...
more »

2017-05-20 10:05 (1) Answers

Data Exchange Between Functions

Yandex Translate I wrote a code like the following. I want to exchange this data between functions on the two pages. In other words, on the page $row variable I want to be able to use on this page, How Can I do that? Google Translate I wrote a code ...
more »

2017-05-20 10:05 (0) Answers

Calling functions in functions - Python

How would I go about to get this to work? I've searched but I can't get it to work still. Should I just put the a() function in the b function even if I add more variables? counter = 1 def a(): az = 1 bz = 2 cz = 3 def b(): a() ...
more »

2017-05-20 04:05 (2) Answers

Javascript grade calculation

I am trying to create a grade calculator whereby; my students can calculate their grade based on grades achieved in set units. I have had an attempt, as you can see from my code below: <script type="text/javascript"> var units = 3; var ocr = 0...
more »

2017-05-19 12:05 (1) Answers

MySQL replace function not specific enough

UPDATE `link_tag` SET `TagID` = replace(TagID, 2, 13) I'm specifically only trying to replace 2 with 13. When I use the above for example 202 becomes 13013 because it is replacing both instances of 2 within the number 202. I only want to replace ...
more »

2017-05-19 08:05 (1) Answers

Error using function in data.table in r

I am using a function in data.table that for some reason does not work when used in data.table but works well when used in the R environment. Will anyone know why this happens? Basically, the function assigns the closest year in an array to a given ...
more »

2017-05-19 01:05 (1) Answers

Dynamically create a function and get a pointer

I am using Arduino and motor encoders to track the rotations of a motor. To do this, I am using interrupts on the Arduino. I can create a function, an ISR, that will be executed by the processor whenever the signal changes on a pin. That Interrupt/IS...
more »

2017-05-18 17:05 (3) Answers

Python: bisection method

I am trying to write a program to determine the zeros of the given function (f(x) := ln((sin(x**(1/2))**3) + 2) - 1, using the bisection method. The values a and b, which are the initial values used in the bisection method, are inserted on the progra...
more »

2017-05-18 15:05 (1) Answers

C++ Array Assignment in Function Issue

C++ newbie here and I have run into an issue which I can't figure out. When I run the code below I get the correct results I expected: #include <iostream> #include <math.h> void factorize(int *factors, int number) { // declare var...
more »

2017-05-18 15:05 (1) Answers

Nested kay value pair in Javascript objects

I am doing a function which should return an object. In this case, query is the initial object, and what I want is adding more key/values to query for example query.location.city but it looks like it is not possible just nesting with . and assign a v...
more »

2017-05-18 15:05 (1) Answers

How to create a global function in qml

I want to create a global function that can be called anywhere in my other qml files. Have tried to put a function inside of a rectangle, but it gives me syntax error in the next object. I don't want to use singleton because the syntax would be like ...
more »

2017-05-18 11:05 (1) Answers

How to make public function

I would like to define function in file functions.ps1 and then call it from another script. Something like this: Functions.ps1: Function Hi() { "hi" } Call it from another script (Call.ps1). Call.ps1: invoke-expression -Command .\functions.ps1 ...
more »

2017-05-18 10:05 (3) Answers

Processing - Initialize function with CP5 button

I have this code that draws hexagons randomly in a grid and coloring them randomly from an array. What I want to do is press a CP5 button to initialize the drawing function. If I press this button again, it will fill all drawn hexagons with black an...
more »

2017-05-18 10:05 (0) Answers

Why getting argument is of length zero` in R?

I have a simple function called PAP. I'm wondering when I run it why I get the following error: Error in if (n.sim < 2) { : argument is of length zero Here is my PAP function: PAP = function (n.sim, sim.time){ n.sim = if(n.sim < 1) { n.s...
more »

2017-05-18 01:05 (1) Answers

Python Passing variables within (sub) functions

I am trying to understand a basic concept about passing variables and scoping in python but I am clearly missing something as I have spent a lot time reading but not getting what I am expecting. I expect the following as: Define global a in main (...
more »

2017-05-17 22:05 (2) Answers

Get name of invoking function in Powershell

I have the following code: function foo () { $sb = (Get-Command bar -CommandType Function).ScriptBlock Invoke-Command -ScriptBlock $sb } function bar () { demo } function demo () { Write-Host $((Get-PSCallStack)[0].Command) Wri...
more »

2017-05-17 17:05 (0) Answers