I want to truncate absolute values below an epsilon to 0, e.g.,
Truncate[{-3, -2, -1, 0, 1, 2, 3}, 1.5] -> {-3, -2, 0, 0, 0, 2, 3}
I guess I could write a function using Scan[] and If[], but is there a more idiomatic "one-liner" way of doing it in Mathematica?
...
I've got a query that looks like this:
select a.title, is.filename
from articles a
join article_images ai on ai.article_id = a.article_id
join images i on i.image_id = ai.image_id
join image_sizes is on is.image_id = i.image_id
where is.size_name = '96x96';
So there is an N:N relationship between articles and images, and an N...
Hello, I have a char variable that is supposed to contain either a Y,y,n or N character, I want to test if it does not contain it, then display an error message and exit the program.
This is the code I am using;
if (userDecision != 'Y' || userDecision != 'y' || userDecision != 'n' || userDecision != 'N')
{
Syste...
I have a number of data containers that can send a signal when there are updates in them. The structure looks similar like this:
typedef struct {
int data;
/*...*/
pthread_cond_t *onHaveUpdate;
} Container;
The onHaveUpdate is a pointer to a global condition that is shared by all the containers
In my application, I have a numbe...
Hi. I have many image/video files should be included as resource. Their size overs 30MB. So it takes to much time when I compile them. This slows down my development speed.
So I'm finding a way to compile those some resource files conditionally. Like #ifdef directive in source code.
It's good if it can be specified in source code file....
I have written a recursive function and depending on the output I need to select different fields. My question is now, how can I do this multiple times without having to call the function more then once? What I'm doing right now is just using the CASE WHEN... condition and checking every time what the functions return. (This is only a ps...
I'm creating a sproc that will insert rows into a 'staging' table with an insert into + subquery like so:
INSERT INTO myStagingTable
SELECT col1, col2, col3
FROM myRealTable
I need to put a conditional in there somehow to determine if the value from col1 for example already exists on myStagingTable, then don't insert it, just skip tha...
Suppose I have something like this:
struct EmptyClass{};
template<typename T1, typename T2 = EmptyClass,
typename T3 = EmptyClass, typename T4 = EmptyClass,
..., typename T20> class PoorMansTuple {
T1 t1;
T2 t2;
...
T20 t20;
};
Now, I may waste up to 19bytes per PoorMansTuple.
Question is:
1) Is there a way...
I have a a conditional comment in my page to fix a double padding-top problem with IE7.
I am trying to add "padding-top:5px;" to a DIV only in IE7. The rest of the browsers (including IE6 and IE8) use "padding-top:10px;" contained in stylesheet.css.
stylesheet.css contains
.clImageSamplerText {padding-top:10px;}
stylesheet_ie7.css ...
So while rewriting some code, I came across something along the lines of:
Method 1
while ( iter.hasNext() ) {
Object obj = iter.next();
if ( obj instanceof Something ) {
returnValue = (Something) obj;
break;
}
}
I re-wrote it as the following without much thought (the actual purpose of the re-write was for...
i have to do something like this in C but it works only if I use a char but I need a string
how can I do?
#define USER "jack" // jack or queen
#if USER == "jack"
#define USER_VS "queen"
#elif USER == "queen"
#define USER_VS "jack"
#endif
thanks to all!
...
Hi,
Is it possible to refer to an attribute of an element conditionally with Jquery?
What I'm after is something like:
$(".mylink":rel["2"]).show();
... which would "show the specific instance of .mylink element on the page that has rel="2" HTML attribute on it. There would be multiple instances of .mylink on the page, each with its...
Hello all,
How would I go about doing the following?
Given the tables, Recipe, RecipeItem, RecipeInstruction. How do I perform a SELECT only if the SELECT statement of Recipe returned results.
If Recipe exists, return RecipeItems and return RecipeInstructions.
...
I have a MySQL query where I would like it to have a pseudo column returned which is based off of:
If columnW does not equal 0, it should be 1 BUT
If columnX does not equal 0, it should be 2 BUT
If columnY does not equal 0, it should be 3 BUT
If columnZ does not equal 0, it should be 4
Hopefully that makes sense. My SQL isn't good en...
Hi,
I have two checkbox on prompt box i.e If user click yes I have to show dtpicker and user click no hidden the dtpicker.
I tried following
$('#yes').click(function(){$('#dtpickerdiv').css("display","block");});
but the hidden div doesn't appear on prompt box?
I tried alerting following
alert -$(‘#dtpickerdiv’).css(“display”) : ...
I am trying to make a method that tests to see if 3 lengths can make a triangle. I think i'm making some kind of syntax error but i can't figure out what it is.
Here is the relevant bit of code: (its in java)
public static void trya (int a, int b, int c)
{
if (c>(a+b))
{
System.out.println ("yes") ;
}
else
...
I'm new to PHP and have a two part question.
I need to take rows from two separate tables, and arrange them in descending order by their date.
The rows do not correspond in order or number and have no relationship with each other.
---EDIT---
They each contain updates on a site, one table holds text, links, dates, titles etc. from a bl...
I'm having trouble simplifying this conditional statements logic. Is there a more effervescent way of writing this?
if(($x || $a) && ($x || $y))
{
if($x){
return true;
}
}
return false;
...
What is an elegant way of writing this?
if (lastSelection != null)
{
lastSelection.changeColor();
}
else
{
MessageBox.Show("No Selection Made");
return;
}
changeColor() is a void function and the function that is running the above code is a void function as well.
...
Hi All,
I am having some trouble with the relative referencing, when trying to cycle through conditional formats in an Excel sheet.
What I am trying to do is loop through the conditions, evaluate them to see if they are true, and if they are, applying the background color of that condition to another cell.
I know that .formula1 has so...