Best way to filter data on site

I write a small application which shows restaurants and pubs. I want to add a function to filter data by category. I get data in my script from external *.json file. There are only two categories - "bar" and "restaurant". I would be very greatful if...
more »

2017-03-19 23:03 (2) Answers

compare splines and polynomials

I'm trying to write a function to compare the basic model between splines and polynomial regression. But when I use model$formula option, that I have in my model, and use it into a gam function with the next variable, I receive an error: Error in...
more »

2017-03-19 17:03 (1) Answers

Very simple cryptography function in C

I'm trying to create a very simple cryptography function that takes a character array and returns another character array with its value increased by one. Precise explanation: The input is a line of text inserted by the user. I expect that the array...
more »

2017-03-19 08:03 (4) Answers

PHP Function two loops from two tables

I've got 2 tables one holds questions and one holds answers. I was wondering if I can grab and echo them through a function. So basically loop through the questions and echo question + answers. Questions +------+-------------------------------+ | q_...
more »

2017-03-19 01:03 (2) Answers

Big 'O' - time complexity of function

Trying to find the time complexity of a function. The function is: def test(self, alt): same = Sample() for i in self.items: if alt.func1(i): same.func2(i) return same func1 has a complexity of O(s) where s is th...
more »

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

error and output issues for python matrix?

I am building a function that takes a list made up of lists (ex: [['a'],['b'],['c']]) and outputs it as a table. I cannot use pretty table because I need a specific output (ex | a | b | ) with the lines and the spaces exactly alike. Here is my func...
more »

2017-03-18 21:03 (2) Answers

Calling a function within the said function

How can i call a def from the same def? I mean, i want to do that: def cal(cal): stat = stat_dict() profile = profile_dict() skill = skill_dict() ... Abreviation.... elif cal == 'Phy': return round(stat['Str']*4 + stat['Con']/3 +...
more »

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

Python functions with multiple parameter brackets

I've been having trouble understanding what h(a)(b) means. I'd never seen one of those before yesterday, and I couldn't declare a function this way: def f (a)(b): return a(b) When I tried to do def f (a, b):, it didn't work either. What do the...
more »

2017-03-18 14:03 (3) Answers

JavaScript resets when changing a page?

I'm building a simple bank account simulator in JavaScript using JSON. I have two pages - "index" which is a login form and "panel", which is client's area. You can acces panel after providing correct data in login form. So, I want to simulate a se...
more »

2017-03-18 12:03 (0) Answers

Haskell - redundant part in function

I have an intricate Haskell function: j :: [Int] j = ((\f x -> map x) (\y -> 3 + y) (\z -> 2*z)) [1,2,3] My guess was that (\y -> 3 + y) (\z -> 2*z) will change to (\w -> 3 + 2*w) and together with f there should be print out the...
more »

2017-03-18 11:03 (2) Answers

Why do we need prototype in function?

I'm studying C and my book is explaining how to "prototype a function" so we can use it before we define it. The point is that I can't imagine a situation in which is needed to use a function before have defined it, why can't we just define it at th...
more »

2017-03-17 23:03 (2) Answers

lambda function explanation

I found the lambda function in internet. I am using it and getting the output correctly. But I need to know the explanation so that i can change the function to my requirements. This function is removing any repeated data in the list I have. But I ...
more »

2017-03-17 21:03 (2) Answers

Get a user-defined function work in data.table

I would like to know how to pass a user-defined function in a data.table. I created the following code using data.table to calculate % of responses 'b' out of all valid responses ('a' or 'b') by two groups; grp1 and grp2: The data (with a warning ...
more »

2017-03-17 18:03 (1) Answers

From Object to Array in JavaScript

I need to write a function that takes in an object and returns an array with this object's property values. Ex.: var obj = { name: "Joao", age: 27, country: "USA" }; The function should return an array like this: var array = ["John"...
more »

2017-03-17 00:03 (4) Answers

PHP's addcslashes ignoring some chars

I would like to know why the function addcslashes() is ignoring certain characters. As you will notice in the output at the bottom, ["`","$","""] are being ignored. This is my example: <?php $ADPasswdRaw = $_GET["element_3"]; #data from a web fo...
more »

2017-03-16 21:03 (0) Answers