Misunderstanding of functions in R

I have a vector p <- seq(0,1,length=11) That I want to use as the independent variable in the summation If I craft a function that codes the summation by hand f <- function(a){ a^0*(1-a)^5+a^1*(1-a)^4+... } and pass it p, then I get t...
more »

2017-10-04 22:10 (3) Answers

How to fire onBlur event in React?

I have an input field value that I want to format onBlur, here is what my code looks like: Component: <Input onBlur={this.formatEndpoint} /> Function: formatEndpoint() { let endpoint = this.state.inputEndpoint; endpoint ...
more »

2017-10-04 18:10 (1) Answers

Python3 Function returning only first values

I'm trying to make a function that opens a textfile, counts the words and then returns the top 7 words in percent. However when I run the code with "return" it only retrieves the first value but "print" gives me what I need + a "None". def count_wfr...
more »

2017-10-04 17:10 (0) Answers

How to stop mail() in php going into spam folder?

I am having a problem with my code when my website send register email to user, it goes into spam folder. This is the picture of email that got to spam. It also says that via gator4168.hostgator.com which what I don't want. This is the code I am us...
more »

2017-10-04 17:10 (1) Answers

Maxima: Translation operator on functions

I would like to define a translation operator L that from a function q outputs q(x-1) for all x i.e. the same function but shifted by one to the left. I defined it this way: (%i0) L(q) := q(x-1); However, if I apply the operator twice (%i1) L(L(q...
more »

2017-10-04 12:10 (1) Answers

Using 'this' in nested functions

Wow.. to get real information about 'this' is not easy as google basically ignores the word. The code opens an image from a database using the information from thumbnail.. the onlick works, and the hover code works, but I can't figure out how to get...
more »

2017-10-04 11:10 (2) Answers

radio buttons in react, ignore null value

so i'm developing a personality quiz app using one of the tutorials i found on the internet //mitchgavan.com/react-quiz/, I have a quizQuestions.js file for api where i fetch the answer and the question from, like so { question: "I am task oriented ...
more »

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

Get name of lambda function as string in Ruby

I have a defined a lambda function as my_lambda = lambda { |x| 100 * x } I am passing this function as an input to another function which needs to verify its identify, something like: def function_verifier(func) if func.to_s == "my_lambda" ...
more »

2017-10-03 21:10 (1) Answers

Weird behavior of a function

In an exercise, I need to compare an array of distances and tell the shortest paths. For this, I need to read an input file with the cities' coordinates (x,y) and find all the possible routes and calculate the total distance of each route. This first...
more »

2017-10-03 17:10 (0) Answers

Calling a returned function

So I am trying to write a general memoizing function in Javascript, using this as my reference material. I've implemented it as instructed: function memoize(func) { var memo = {}; var slice = Array.prototype.slice; return function() {...
more »

2017-10-03 16:10 (1) Answers

PySpark Window Function Comprehension

I have been using PySpark to run a large number of calculations in a fairly large RDD whose each block look like this: ID CHK C1 Flag1 V1 V2 C2 Flag2 V3 V4 341 10 100 TRUE 10 10 150 FALSE 10 14 341 9 100 TRUE 10 10 150 FA...
more »

2017-10-03 16:10 (1) Answers

What is wrong with my function and for-loop?

I am currently trying to count the absolute number of countries in a long string. I have loaded a data frame named "countries" with column "Countries", consisting of all countries in the world. I want to make a function that searches any string, loop...
more »

2017-10-03 14:10 (2) Answers

How to debug a user defined function

The user defined function below is causing duplicates and this causing a build to fail. What is the best approach to test each part of the function so I can pinpoint where the issue is? And assistance would be a huge benefit. I've never really had ...
more »

2017-10-03 11:10 (1) Answers

SML function that takes a filename and a list

I want to write a function that takes a filename as a string and a list of pairs of characters. This function must open the named file, read the contents of the file, and echo the characters to the screen. Any occurrence of a character in the first p...
more »

2017-10-03 08:10 (1) Answers

Passing a list of argument sets to a function

I've made a little progress on my understanding since submitting the poorly posed question below. I've gotten as far as this: from collections import namedtuple a = 3 Data = namedtuple('Data', 'b c') d1 = Data(4,5) d2 = Data(6,7) data_list = (d1, d2...
more »

2017-10-02 17:10 (3) Answers

How do i call a function within a function?

i'm creating a mini program in pascal to read music albums. The problem i'm facing is calling the readTracks() function within my readAlbum() function. Any help would be great, thank you :) The current error when executing the code is: Error: Incomp...
more »

2017-10-02 16:10 (2) Answers