logic

Testing if a file exists in a make file

自作多情 提交于 2020-01-16 01:58:46
问题 I need to add some logic to a make file and I am stuck. I see several examples out there but I'm not sure which one is the right one for me. What I have: $(UBIN)/%: $(CC) $(CFLAGS) -o $(UBIN)/$* $(OBJS) -L $(ORAHOME) $(ORALIBS) \ $(LNKPATH) $(DSTN_LIBS) @echo "" What I want: $(UBIN)/%: If the file $(UBIN)/$* exists then $(CC) $(CFLAGS) -o $(UBIN)/$* $(OBJS) -L $(ORAHOME) $(ORALIBS) \ $(LNKPATH) $(DSTN_LIBS) @echo "" endif But I can't figure out what the right syntax is. Some idea were to use

How to hide or delete the zero in my bash script?

左心房为你撑大大i 提交于 2020-01-15 15:33:51
问题 This is my script: echo -n "number 1 :"; read bil1 echo -n "number 2 :"; read bil2 multiple=$(echo $bil1*$bil2 |bc -l |sed -e 's/^\./0./' -e 's/^-\./-0./'); echo " Your result : $bil1 * $bil2 = $multiple "; If I input 9.5 for $bil1 and 300 for $bil2 , the result is 2850.0 . I want the result: Your result : 9.5 * 300 = 2850 How do I hide or delete the zero at the end of the result? I.e. show only 2850 ? 回答1: Add the following part to your sed command (at the end): -e 's/\.0*$//' (Delete a dot

How to hide or delete the zero in my bash script?

余生颓废 提交于 2020-01-15 15:31:15
问题 This is my script: echo -n "number 1 :"; read bil1 echo -n "number 2 :"; read bil2 multiple=$(echo $bil1*$bil2 |bc -l |sed -e 's/^\./0./' -e 's/^-\./-0./'); echo " Your result : $bil1 * $bil2 = $multiple "; If I input 9.5 for $bil1 and 300 for $bil2 , the result is 2850.0 . I want the result: Your result : 9.5 * 300 = 2850 How do I hide or delete the zero at the end of the result? I.e. show only 2850 ? 回答1: Add the following part to your sed command (at the end): -e 's/\.0*$//' (Delete a dot

[PHP]: Logic with date differences

纵饮孤独 提交于 2020-01-15 12:15:38
问题 I'm seeking an elegant solution to change the format of time based on the length of time between now, and a ISO formated date in a DB. I'd like the output to look something like this //less than an hour 'X minutes have gone by' //less than 24 hours 'X hours have gone by' //greater than 24 hours ISO date Here is what I have so far... $now = date("o-m-d H:i:s") //now = something like '2009-12-28 16:39:00' $dateExample = '2009-12 16:37:00' $timeSpan = round(strtotime($now) - strtotime(

Can XOR be expressed using SKI combinators?

那年仲夏 提交于 2020-01-15 03:39:24
问题 I have question about SKI-Combinators. Can XOR (exclusive or) be expressed using S and K combinators only? I have True = Cancel False = (Swap Cancel) where Cancel x y = K x y = x Swap: ff x y = S ff x y = ff y x 回答1: Booleans Your question is a bit unclear on the details, but it seems that what you mean is that you have the following representation of booleans: T := K F := S K This works because it means the following reductions hold: T t e => t F t e => e in other words, b t e can be

Square Spiral Co-ordinate

天涯浪子 提交于 2020-01-14 07:12:07
问题 I want to find if a point (x,y)where x,y integers satisfy the spiral square. (0,0) (0,1) (1,1) (1,2) (0,2) (-1,2) (-2,2) (-2,1) (-2,0) ans so on..... How do I do it? I want the logic for a java or c++ function. 回答1: Here is some pseudocode logic: Start with x=0, y=0, dist=0, direction=1 Loop x += (++dist * direction) WritePoint(x,y) y += (++dist * direction) WritePoint(x,y) direction *= -1 LoopEnd Take it from there. 回答2: Do this operation: (operator)(operation)(amount) where operator

constructing a square matrix of edge N, and its element should not be same across same row and column

江枫思渺然 提交于 2020-01-14 07:07:44
问题 So, I was constructing a matrix (square) of length N, its element i should between 1 <= i < 2 * N Each element should be between 1 to 2 * N - 1 for each i and j (1 <= i <= N and 1 <= j < 2 * N ) the j element should appear in i th row / i column for any N if the desired matrix is not possible we have print -1; Which means for N = 2 We could get matrix as - 1 2 3 1 As we can see for 1st row and column we can get 1 , 2 , 3. and for 2nd row and column we get 1, 2, 3 Another example : for N = 4 1

Is MySQL logic evaluation lazy/short-circuiting in JOIN clause?

南楼画角 提交于 2020-01-13 08:37:06
问题 Take the following expression: FALSE AND (expression) Will MySQL evaluate the expression or just move on as soon as it sees FALSE ? Some background context-- I wanted to speed up a query by doing: JOIN... ON (indexed_column1=indexed_column2 AND non_indexed_column_a=non_indexed_column_b) For background on why I'm doing this query see this answer If it's going to always evaluate non_indexed_column_a=non_indexed_column_b then no time is saved with that. 回答1: The MySQL query optimizer uses

Why are products called minterms and sums called maxterms?

血红的双手。 提交于 2020-01-11 15:30:09
问题 Do they have a reason for doing so? I mean, in the sum of minterms, you look for the terms with the output 1; I don't get why they call it "minterms." Why not maxterms because 1 is well bigger than 0? Is there a reason behind this that I don't know? Or should I just accept it without asking why? 回答1: The convention for calling these terms "minterms" and "maxterms" does not correspond to 1 being greater than 0. I think the best way to answer is with an example: Say that you have a circuit and

Is it possible to correct page dimensions by getting three points on it?

丶灬走出姿态 提交于 2020-01-11 11:42:10
问题 I am working on a logic of correcting width, height and angle of page(image). Point r1,r2,r3 are on correct image and Point d1,d2,d3 are corresponding points on current image. I have tried multiple approach and have landed on this. public System.Drawing.Bitmap CorrectFileDimentionsV2(System.Drawing.Bitmap bitmap, PagePoints pagePoints) { BitmapHelper bitmapHelper = new BitmapHelper(); var bitmapImage = bitmapHelper.Bitmap2BitmapImage(bitmap); DrawingVisual MyPath = new DrawingVisual(); using