dollar-sign

Dollar operator as function argument for sapply not working as expected

China☆狼群 提交于 2019-12-03 10:55:58
I have the following list test_list=list(list(a=1,b=2),list(a=3,b=4)) and I want to extract all elements with list element name a . I can do this via sapply(test_list,`[[`,"a") which gives me the correct result #[1] 1 3 When I try the same with Rs dollar operator $ , I get NULL sapply(test_list,`$`,"a") #[[1]] #NULL # #[[2]] #NULL However, if I use it on a single element of test_list it works as expected `$`(test_list[[1]],"a") #[1] 1 Am I missing something obvious here? NGaffney From what I've been able to determine it's a combination of two things. First, the second element of $ is matched

Is there an inverse of the Haskell $ operator?

守給你的承諾、 提交于 2019-12-03 06:18:57
问题 A quick question, is there an operator in Haskell that works like the dollar sign but gives precedence to the left hand side. I.E. instead of f (x 1) being written as f $ x 1 I'd like to write it as x 1 $ f This is purely a stylistic thing. I'm running a sequence of functions in order and it would be nice if I could write them left to write to match that I read left to write. If there an operator for this? [update] A couple of people have asked if I can't define my own. In answer, I wanted to

Is there an inverse of the Haskell $ operator?

大兔子大兔子 提交于 2019-12-02 19:57:14
A quick question, is there an operator in Haskell that works like the dollar sign but gives precedence to the left hand side. I.E. instead of f (x 1) being written as f $ x 1 I'd like to write it as x 1 $ f This is purely a stylistic thing. I'm running a sequence of functions in order and it would be nice if I could write them left to write to match that I read left to write. If there an operator for this? [update] A couple of people have asked if I can't define my own. In answer, I wanted to check there wasn't an existing operator before I reinvented the wheel. As of GHC 7.10 ( base 4.8.0.0),

Tcl adds curly braces when using `$` sign

北城以北 提交于 2019-12-02 02:52:44
set B {pc_0::!mx_0 pi::$mx_0} puts $B set A "" foreach x $B { lappend A $x } puts $A The output of this program is pc_0::!mx_0 pi::$mx_0 pc_0::!mx_0 {pi::$mx_0} It is strange that tcl adds curly braces in second output. I guess it is because it uses $ symbol. But I really need to use it and I don't want the braces to be inserted. How this can be explained and how to avoid the braces? As a general rule, don't treat lists as strings . Pretend that they don't have a string representation. (The string representation is only useful for serialization, debugging, but not for the user). To convert

PowerShell: -replace, regex and ($) dollar sign woes

不羁的心 提交于 2019-12-01 18:35:07
I am in the process of converting thousands of lines of batch code into PowerShell. I'm using regex to help with this process. The problem is part of the code is: $`$2 When replaced it just shows $2 and doesn't expand out the variable. I've also used single quotes for the second portion of replace instead of escaping the variables, same result. $origString = @' IF /I "%OPERATINGSYSTEM:~0,6%"=="WIN864" SET CACHE_OS=WIN864 ...many more lines of batch code '@ $replacedString = $origString -replace "(IF /I `"%)(.+)(:.+%`"==`")(.+`")(.+)","if ( $`$2 -match `"^`$4 ) {`$5 }" $replacedString You could

Meanings of dollar sign in Java method descriptor?

我的梦境 提交于 2019-11-30 09:35:15
For example, its part of the Jikes RVM stack. at [0x70cfba90, 0x708cfaa4] Lorg/apache/lucene/index/SegmentInfos; **access$000**(Ljava/lang/String;)V at [0x70cfbb04, 0x708b55c8] Lorg/apache/lucene/index/SegmentInfos$ FindSegmentsFile; run()Ljava/lang/Object; at line 554 at [0x70cfbb24, 0x708c4a8d] Lorg/apache/lucene/index/SegmentInfos; read(Lorg/apache/lucene/store/Directory;)V at line 272 'access' should be a method name. But I checked the class source code and its interfaces, there is no method there called 'access'. I couldn't find an answer on Google, since Google hates all kinds of

Dollar sign before a variable

偶尔善良 提交于 2019-11-29 23:00:45
I have this sample code to create a new data frame 'new_data' from the existing data frame 'my_data'. new_data = NULL n = 10 #this number correspond to the number of rows in my_data conditions = c("Bas_A", "Bas_T", "Oper_A", "Oper_T") # the vector characters correspond to the target column names in my_data for (cond in conditions){ for (i in 1:n){ new_data <- rbind(new_data, c(cond, my_data$cond[i])) } } The problem is that my_data$cond (where cond is a variable, and not the column name) is not accepted. How can I call a column of a data frame by using, after the dollar sign, a variable value?

Meanings of dollar sign in Java method descriptor?

有些话、适合烂在心里 提交于 2019-11-29 14:16:18
问题 For example, its part of the Jikes RVM stack. at [0x70cfba90, 0x708cfaa4] Lorg/apache/lucene/index/SegmentInfos; **access$000**(Ljava/lang/String;)V at [0x70cfbb04, 0x708b55c8] Lorg/apache/lucene/index/SegmentInfos$ FindSegmentsFile; run()Ljava/lang/Object; at line 554 at [0x70cfbb24, 0x708c4a8d] Lorg/apache/lucene/index/SegmentInfos; read(Lorg/apache/lucene/store/Directory;)V at line 272 'access' should be a method name. But I checked the class source code and its interfaces, there is no

What does the $ mean when running commands?

青春壹個敷衍的年華 提交于 2019-11-29 06:31:54
I've been learning Python, and I keep running into the $ character in online documentation. Usually it goes something like this: $ python ez_setup.py (Yeah, I've been trying to install setup tools) I'm fairly certain that this command isn't for the python IDE or console, but I've tried windows cmd and it doesn't work. Any help? As of now, Python does not implement $ in its syntax. So, it has nothing to do with Python. Instead, what you are seeing is the terminal prompt of a Unix-based system (Mac, Linux, etc.) When you open up command prompt in Windows, you'll see something like: C:\Users

What does the “$$” mean in Postgresql function?

本秂侑毒 提交于 2019-11-29 05:07:53
CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS $$ BEGIN RETURN i + 1; END; $$ LANGUAGE plpgsql; The above code is taken from the Postgresql website. However I do not understand why $$ is used. I have seen it at multiple examples online and none of them actually explains why that is used. Or is it even necessary? From the manual for the create function statement: definition A string constant defining the function; the meaning depends on the language. It can be an internal function name, the path to an object file, an SQL command, or text in a procedural language. It is often