parentheses

Parentheses for subshell don't work when stored in a variable

徘徊边缘 提交于 2019-12-25 04:24:30
问题 The command: ( echo 1 ) works fine when I input it in the command line but if I store it as a variable and call it, it gives the error: (echo: command not found Code: input="( echo 1 )" $input Why doesn't it evaluate the parentheses the same way and put it into a subshell when I call it this way? 回答1: This is discussed in full detail in BashFAQ #50. An unquoted expansion goes through only two stages of shell parsing: Field-splitting, and glob expansion. Thus, ( echo 1 ) is first split into

Why is UNION ALL with and without parenthesis behaving different?

淺唱寂寞╮ 提交于 2019-12-24 16:33:30
问题 I have this query implemented in two ways: SELECT race1, mode1 FROM organization WHERE condition = 1 LIMIT 1 UNION ALL (SELECT race2, mode2 FROM organization WHERE condition = 1 LIMIT 1) UNION ALL (SELECT race, mode FROM organization_new WHERE PK_Id = 1) And SELECT race1, mode1 FROM organization WHERE condition = 1 LIMIT 1 UNION ALL SELECT race2, mode2 FROM organization WHERE condition = 1 LIMIT 1 UNION ALL SELECT race, mode FROM organization_new WHERE PK_Id = 1 As you can see, the difference

Regex find whole substring between parenthesis containing exact substring

匆匆过客 提交于 2019-12-24 11:26:48
问题 For example I have string: "one two (78-45ack sack); now (87 back sack) follow dollow (59 uhhaaa)" and I need only whole substring with parenthesis, containing word "back" , for this string it will be: "(87 back sack)" I've tried: (\(.*?back.*?\)) but it's return "(78-45ack sack); now (87 back sack)" How should my regex look like? As I understood it's happening cause search going from begin of the string, in common - how to perform regex to "search" from the middle of string, from the word

Reordering parentheses using associative property in Racket

别来无恙 提交于 2019-12-24 06:37:16
问题 I am having trouble implementing a function that given something like this: '((+(d + e) + f) + (a + (a + c)) Returns this: '(d + (e + (f + (a + (a + c))))) Now the catch is that I have to use associativity to get the answer so I only want to use this property: '((a + b) + c) = '(a + (b + c)) To get the correct output. I know how to implement the function for this case: '((a + b) + c) -> '(a + (b + c)) However I cannot seem to figure out how to implement it for the first case above (or any

Substitute parenthesis for their regular expression

心不动则不痛 提交于 2019-12-24 01:18:10
问题 I'm trying to copy a file, >>> originalFile = '/Users/alvinspivey/Documents/workspace/Image_PCA/spectra_text/HIS/jean paul test 1 - Copy (2)/bean-1-aa.txt' >>> copyFile = os.system('cp '+originalFile+' '+NewTmpFile) But must first replace the spaces and parenthesis before the open function will work: /Users/alvinspivey/Documents/workspace/Image_PCA/spectra_text/HIS/jean\ paul\ test\ 1\ -\ Copy\ \(2\)/bean-1-aa.txt spaces ' ' --> '\ ' parenthesis '(' --> '\(' etc. Replacing the spaces work: >>

Unexpected closing parentheses in batch file with matching start

∥☆過路亽.° 提交于 2019-12-24 00:49:44
问题 I have a simple batch file that currently all it does it tries to connect to a wifi network up to 10 times. My trouble is that I am getting an unexpected output in my command prompt when it is ran. Here is my batch script setlocal EnableExtensions EnableDelayedExpansion echo. echo. :startSetVariables set timeout="2" set PINGS="4" set pingtimeout="1000" set endonfail="10" set wifissid="ROGAR Production" set /A COUNTER=1 :connectToTheInternet echo checking internet connection echo.

Parsing string with nested parentheses using Parse::RecDescent

跟風遠走 提交于 2019-12-23 20:07:40
问题 I'm trying to use Parse::RecDescent make a parser which can parse parenthetical expressions and the unary operator ? . What I have so far is failing when I create the parser because the rule expression is left-recursive: use strict; use warnings; use Parse::RecDescent; my $test = <<END; ((foo)? bar) END my $grammar = q( parse: expression(s) expression: string | parend | expression(s) parend : "(" (string | expression) ")" /\??/ string : /\w+/ /\??/ ); my $parser = Parse::RecDescent->new(

Coffeescript: invoking function with space before parens

旧街凉风 提交于 2019-12-23 19:34:06
问题 When I invoke a function with a space before the parens, it gives an error saying unepected , sum = (a, b) -> a+b console.log (sum (1, 2)) error: unexpected , console.log (sum (1, 2)) it points to the comma between 1 and 2 Why the odd behavior? 回答1: In CoffeeScript you can write function calls in two ways: foo(bar) # with parens foo bar # without parens Since you have a space between sum and (1, 2) , then you are making a unparenthesized functional call of sum passing (1, 2) as the first

Swift Types inside Parentheses

China☆狼群 提交于 2019-12-23 17:04:19
问题 I was playing around with Swift today, and some strange types started to crop up: let flip = Int(random()%2) //or arc4random(), or rand(); whatever you prefer If I type flip into Xcode 6 (Beta 2), the auto-complete pops up, and says flip is of type (Int) instead of Int . This can easily be changed: let flip : Int = Int(random()%2) let flop = random()%2 Now flip and flop are of type Int instead of (Int) Playing around with it more, these "parentheses types" are predictable and you can cause

What is the dominant style for parenthesization of Ruby function calls?

放肆的年华 提交于 2019-12-23 11:15:12
问题 Say I have func_a and func_b which both take one argument, and I want to pass the result of func_b to func_a . What is the most common way to parenthesize this? func_a func_b input func_a func_b(input) func_a(func_b input) func_a(func_b(input)) 回答1: You'd have to scan source to find the "most common". I try to write what makes sense under the circumstances, but would almost always use either: func_a func_b(arg) func_a(func_b(arg)) If the functions are named things that "sound like" a sentence