function,parameters,lisp,common-lisp , LISP function to return the greater number

## Question:

Tag: function,parameters,lisp,common-lisp

I feel like an idiot asking for help for this, but I have been stuck for hours now, and I haven't been able to find anything on the internet that can help me.

I am trying to write a function in LISP that takes in two parameters and returns the number that is greater. Here's what I have at the moment, but I keep getting errors:

(defun greater (x y)
(if (> x y) x y))

I am calling it like this:

(greater (2 1))

I'm not a Common Lisp expert, but I guess the way you are calling greater is wrong. This program works for me:

(defun greater (x y) (if (> x y) x y))

(print (greater 5 12))

# Related:

## How to skip a function

function,python-2.7
I am learning python and trying to make a little game. So my question is can you define a function but skip it and use it later. EX. def func() print"1,2,3,4" func() def func2() print "counting" func() func2() How would I skip func but still be able to print it...

## Update input number variable onclick

javascript,jquery,html,function
I am trying to create a calculator style thing, where you put in how many years into a input, you hit submit and it gives you different results below without reloading the page. I have all the calculations working right now, but I just cant get the input number variable...

## PercentOfSum(fld, condfld) SSRS Equivalent

function,reporting-services,crystal-reports,ssrs-2008,ssrs-2008-r2
Crystal Reports has a built-in function PercentOfSum(fld, condfld) (documentation here). How can I achieve the same functionality in SSRS?

## My is_prime function fails on 9, and I don't know why?

python,function
I have a bit of a problem. I am writing an is_prime function on, but whenever I run it, it fails on is_prime(9), and I cannot see why: def is_prime(x): if x < 2: ##because negative numbers, 0 and 1 are not prime## return False elif x == 2: return...

## How can I simulate a nested function without lambda expressions in C++11?

c++,function,c++11,lambda,allegro
I have the following code: int main(int argc, char **argv) { App app(800, 600); app.add_event_scene(Scene("Event Plot", event_plot)); Image x("sample.png"); struct foo { static void visual_plot() { x.draw(); } }; // Error. app.add_visual_scene(Scene("Visual Plot", foo::visual_plot)); app.run(); return 0; } And I get the following error: ||=== Build: Debug in Joy-Plus-Plus (compiler:...

## How do I return a value from a second function in PHP?

php,function,return,value
I'm a green green newbie trying to write a simple program in PHP. I use an HTML form to ask a "diner" to select an entree, which sends the choice to a PHP program.The PHP program is supposed to echo the entree choice, suggest a drink to the diner, and...

## jQuery - Value in Function

jquery,arrays,function
My array: array.name = "Thiago"; array.date = "01/01/1990"; I want a function like this: function myFunc( array, fieldToCompare, valueToCompare ) { if( array.fieldToCompare == "Thiago" ) alert(true); } myFunc( myArray, name, "Thiago" ); is it possible?...

## Stopping condition on a recursive function - Haskell

So, I have this function which aims to align the text on the left without cutting words(only white spaces). However my problem is that I cannot find a stopping condition of the function and it goes infinitely. f n "" = "" --weak condition f n s = if n...

## MySQL function with parameters syntax error

mysql,regex,function
I'm trying to convert this query to a MySQL function SET @v1 := ( SELECT count(id) as count FROM article_category where (title like "About Usd") or (title like "About Usd-%" and title regexp '[0-9]\$') ); INSERT INTO `article_category` (`title`,`meta_data`,`meta_description`) VALUES ( IF(@v1 <= 0, "About Usd", CONCAT("About Usd","-",@v1) ), "ddddD",...

c,function,serial-port,posix
I get confused with one line of code: temp_uart_count = read(VCOM, temp_uart_data, 4096); I found more about read function at http://linux.die.net/man/3/read, but if everything is okay it returns 0, so how we can get num of bytes received from that? temp_uart_count is used to count how much bytes we received...

## Delete file after “x” second after creation

vb.net,function
I want to delete file after 15 second of create that file. I use this code but no success. Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click Dim test = Application.StartupPath & "\" + tte4 Timer1.Enabled = True If Timer1.Interval = 0 Then My.Computer.FileSystem.DeleteFile(test) End If End Sub...

## Django: Handling several page parameters

python,django,list,parameters,httprequest
I have several possible parameter to process in a page. Assume x0, x1, x2,..., x1000. It seems awkward to get and process them one by one by request.GET.get('x0'), request.GET.get('x1'), ... Any idea to put them in a list, so that they can be processed in a loop....

## Global scope for array of structs inside function - Swift

arrays,function,swift,struct,shuffle
I would like to shuffle my array questions and use the shuffled array in the program when it starts. I have created this function that shuffles the array. func shuffleQuestions() { var shuffledQuestions = shuffle(questions) } This gives me an array with questions shuffled that inherits the values from the...

## SQL average age comparison function returns null

mysql,sql,function,datetime
So, I'm working in MySQL, writing a function that averages the ages of women and men from a table and compares them, and returns which is greater. Dates are in the format of YYYY-MM-DD, and I'm using DATEDIFF(). The function appears to work correctly, but when I run the script,...

## Use a function with parameters inside a callback

javascript,parameters,callback
I've written a function which may take an unknown number of functions as parameters, but can't figure how I can make this work when one or more of the functions take parameters too. Here is a quick example of what I would like to achieve: function talk(name) { console.log('My name...

## Selecting and removing a html select option without selecting by index or ID, using vanilla JavaScript

javascript,function,select,options
I need to remove an option on a select box, and I've figured out a potential solution in the code below, but it doesn't feel particularly 'safe' (if another developer decided to add an option to the backend, the option will re-appear). Is there a better way of achieving this...

## Genetic Algorithm - convergence

java,algorithm,function,genetic-programming,convergence
I have a few questions about my genetic algorithm and GAs overall. I have created a GA that when given points to a curve it tries to figure out what function produced this curve. An example is the following Points {{-2, 4},{-1, 1},{0, 0},{1, 1},{2, 4}} Function x^2 Sometimes I...

## Why doesn't this swift function work?

string,function,swift
This function takes two string arguments. It is supposed to return the first one as dashes except where the character is somewhere inside of the second argument. Example: dashes_except("hello", except: "lo") -> --llo The function works fine when the except argument is only one letter but fails when it is...

## Why can we use undefined object in Javascript function declaration?

javascript,function
Chromium WebUI has a cr.js file, which offers cr.define( name, fun ) method, for modulization. All the porperties of the object that fun returns, will be added to the name namescope object. In chromium browser bookmarks manager page(chrome://bookmarks), a Javascript source file named bmm.js is loaded. This is a Javascript...

## How does ((a++,b)) work? [duplicate]

c,function,recursion,comma
This question already has an answer here: What does the comma operator `,` do in C? 8 answers In the below block of code, I am trying to understand how the line return reverse((i++, i)) is working. #include <stdio.h> void reverse(int i); int main() { reverse(1); } void reverse(int...

## is return main(); a valid syntax?

c,function,return,language-lawyer,return-type
I found some interesting code lines: #include <stdio.h> int main() { printf("Hi there"); return main(); } It compiles ok (VS2013) and ends up in stackoverflow error because of the recursive call to main(). I didn't know that the return statement accepts any parameter that can be evaluated to the expected...

I'm reading Secrets of Javascript Ninja and came across an example that I cannot fully understand. This same example was cited by some other user here before, but their doubts are different than mine. Here is the example: function addMethod(object, name, fn) { var old = object[name]; object[name] = function(){...

## JavaScript recursive function breaks when () included in call

javascript,jquery,function
I have created a countdown "Pomodoro" timer using JavaScript and JQuery. The code snippet I am referring to is the following: var time = 1500; var cycle = "long"; var tracker = 0; var paused = false; //Timer countdown function function countdown(){ if (!paused) { var seconds = ("00" +...

## strip_tags() on MySQLi Query and PHP Function [closed]

php,mysql,string,function,mysqli
I'm trying hard to learn how to create functions, and I don't know what I'm doing wrong here. Could someone explain it to me please? I'm not using strip_tags(), why it's getting me this error? I don't need it to return, I just to need to update database if \$xp...

## C++ need help figuring out word count in function. (Ex. Hello World = 2)

c++,function
I'm figuring out the algorithm on this function and it keeps crashing at runtime, here's the code snippet: int wordCounter(char usStr[]) { int index= 0, punct= 0; while(usStr[index]!= '\0') //If it's not the end of the sentence if(usStr[index]== ' ') //If it finds a space index++; while(usStr[index]== '\0') //If it's...

## JSLint won't recognize getElementById

javascript,function,getelementbyid,jslint
JSLint gives errors with simple function, running on brackets with JSLint. Javascript: function soundSorry() { getElementById("player").play(); } Error codes: 2 Missing 'use strict' statement. getElementById("player").play(); 2 'getElementById' was used before it was defined. getElementById("player").play(); Any ideas?...

## PHP - url path as parameters

php,url,parameters
My question might be silly, but I have no idea how to do it. I'm using PHP for creating websites. To change content of the page there is script which includes different file based on url parameter, eg. http://example.com/index.php?page=news This loads some news page. When I want to load some...

## Calling function and passing arguments multiple times

python,function,loops
I want to call the function multiple time and use it's returned argument everytime when it's called. For example: def myfunction(first, second, third): return (first+1,second+1,third+1) 1st call: myfunction(1,2,3) 2nd call is going to be pass returned variables: myfunction(2,3,4) and loop it until defined times. How can I do such loop?...

## Call known function (with parameters) in class whose name is defined by string variable

java,function,class,variables
I have a bunch of classes of various names and each has a performLogic function that accepts a number of preset parameters (always the same): public final class DoSomeAction extends SetupAction { public void performLogic(param1, param2... I want a way where I can call it like this: String actionName =...

## Decremented value called in the recursion in Haskell

So, I have this function that aligns the text to the left for a given column width. I have already fixed some of its problems, but I am unable to make it not use the decremented parameter once it is called, but to return to the starting value of n....

## Is it possible to use \$(this) in a function called from another function?

jquery,function,this
Sorry for the question title, I know it's not very well worded, but I couldn't really explain what I'm asking in a summary. I have a JQuery function tied to the click event of an element. For reasons that may well be flawed (other than making more sense to me...

## Stuck on Structs(c++)

c++,function,struct
Okay so this is what Ive been asked to do "make a struct called Coordinate that contains the latitude and longitude of a point on the surface of the Earth. The struct should also store a label or name for the coordinate (e.g., “Calgary”). Both the latitude and longitude member...

## XQuery - Doing math on elements within a sequence and aggregating results

function,operators,xquery,sequence,aggregation
I'm trying to execute a XQuery sum function in a multiplication of two XML elements, but it has been difficult to avoid the iteration in a sequence of elements. For example, consider this case: sample data: <Orders> <Order> <OrderKey>1</OrderKey> <LineItem> <LineNumber>1</LineNumber> <Quantity>41</Quantity> <ExtendedPrice>70848.0000</ExtendedPrice> <Discount>0.0913</Discount> <Tax>0.0663</Tax> <ReturnFlag>A</ReturnFlag>...

## sum of Digits through Recursion

java,function,recursion,sum,digit
I am trying to make a recursive function which should return the sum of digits. The function should have only one argument. So far I have this; public int sumDigits(int n) { if(n%10 == n) // last digit remains return n; else{ int rightdigit; rightdigit = n%10; // taking out...

## session value in javascript cannot be set

javascript,function,session
I am quite new to javascript, I wonder why my session value in javascript wont be set to 1 even I tried. When call this function again, the value of the session will change again. My javascript code as below. <script type="text/javascript"> function Confirm() { alert(<%=Session["Once"]%> != 1); var value...

## Casting a String Into a Function in R

r,function,casting
I have a Shiny app in R where I want users to be able to create functions on the fly by entering text in a text box. To enable this functionality, I would like to know the following: How would I go about casting a string object containing a function...

## How can I minimize this function in R?

r,function,optimization,mathematical-optimization
I'm attempting to write a formula that will determine a value of a that minimizes the function output myfun (i.e. a-fptotal). MWE: c <- as.matrix(c(.25,.5,.25)) d <- as.matrix(c(10000,12500,15000)) e <- 700 f <- 1.1 tr <- .30 myfun <- function(a) { b <- max(a-e,0) df <- data.frame(u1=c(c*b*.40),u2=c(c*b*.60)) df\$year <- 1:nrow(df)...

## How to pass pointer to struct to a function?

c,function,pointers,struct
I am instantiating the struct within the main() function and I am passing a pointer to this structure over to a function. I would like to then pass this pointer to the original struct to another function, how would I do this? I am now lost in pointerception. struct coords...

## How to call a data.frame inside an R Function by name

r,function,data.frame,call
I want to write a function that runs the same analysis on different data.frames. Here is a simple version of my code: set1 <- data.frame(x=c(1,2,4,6,2), y=c(4,6,3,56,4)) set2 <- data.frame(x=c(3,2,3,8,2), y=c(2,6,3,6,3)) mydata <- c("set1", "set2") for (dataCount in 1:length(data)) { lm(x~y, data=mydata) } How do I call a data.frame by name...

## My function will log a value to the console, but it won't return the same value - why? [duplicate]

javascript,arrays,function,recursion
This question already has an answer here: Return value of recursive function is 'undefined' 1 answer I've created the following function to flatten a nested array: function steamroller(arr) { arr = arr.reduce(function(a, b, i){ return a.concat(b); },[]); if (!Array.isArray(arr[arr.length-1])) {console.log(arr); return arr;} steamroller(arr); } steamroller([1, [2], [3, [[4]]]]); The...

## Interpret formulae/operators as functions

r,function,variable-assignment,formula,evaluation
Is it possible in R to assign custom functions to mathematical operators (eg. *, +) or interpret the formulae supplied with as.formula() as a directive to evaluate? Specifically, I would like * to be interpretted as intersect(), and + as c(), so R would evaluate the expression (a * (b...

## function pointer is not a function or function pointer

c++,function,pointers
I have following problem: void MyClass::LoopFunction(vector<Item>& items,void (MyClass::*funcy)(vector<Item>&,int)) { for(SInt32 i = 0; i < 50; i++) { funcy(items,i); } } It says: Called object type 'void(MyClass::*)(vector<Item>&,int)' is not a function or function pointer Can anyone help me to find a solution for this?...

## Can anyone improve on the below Fuzzyfind function for VBA?

algorithm,vba,function,find,fuzzy-search
This function lets you find similar strings from a range without having to do an exact search. The formula looks like this: =FuzzyFind(A1,B\$1:B\$20) assuming the string you are performing a search for is in A1 and your reference or options table is B1:B20 The code is here: Function FuzzyFind(lookup_value As...

## How to return an array with unhappy numbers removed?

matlab,function
I'm quite new to using MATLAB, and am still trying to understand how to make this particular function. I understand the formula for performing this on paper, but I'm having trouble translating it into the required MATLAB syntax. How would a function be written such that it takes an array...

## Toggle text + also call method with argument?

jquery,function,toggle
Im trying to toggle change a text on spacebar press with jquery ( works ) but also try to call a method with custom argument. How would below code example needs to me modified to do this? I have tried all kinds of ways but don't understand how to add...

## NodeJS / ExpressJS check valid token parameter before routing

node.js,express,parameters
I have the following app code: (app.js) var express = require('express') , app = express() , port = process.env.PORT || 8082 app.use(require('./controllers')) app.use(function(req, res, next) { res.send('Test') next() }) app.listen(port, function() { console.log('Listening on port ' + port) }) and two controllers: (index.js) var express = require('express') , router =...