substitution

Compare datasets in R

大城市里の小女人 提交于 2019-12-23 13:13:42
问题 I have gathered a set of transactions in a CSV file of the format: {Pierre, lait, oeuf, beurre, pain} {Paul, mange du pain,jambon, lait} {Jacques, oeuf, va chez la crémière, pain, voiture} I plan to do a simple association rule analysis, but first I want to exclude items from each transactions which do not belong to ReferenceSet = {lait, oeuf, beurre, pain} . Thus my resulting dataset would be, in my example : {Pierre, lait, oeuf, beurre, pain} {Paul,lait} {Jacques, oeuf, pain,} I'm sure this

Sphinx variable substitution in code blocks

谁都会走 提交于 2019-12-23 07:59:24
问题 Using Sphinx 1.2.3 and given this RST snippet: .. code-block:: xml <foo> <bar>|version|</bar> </foo> and in conf.py I have: version = '1.0.2' How do you ensure that the above RST snippet renders as: <foo> <bar>1.0.2</bar> </foo> This previous question indicates that we should use .. parsed-literal:: instead of .. code-block:: , but that does not work, nor does the referenced link in that question work either. I also want to retain syntax highlighting. 回答1: You can get the wanted output by

Non standard evaluation in Hadley's advanced R book

时光毁灭记忆、已成空白 提交于 2019-12-23 07:47:08
问题 In Hadley's Advanced R book, there is a piece of code that I cannot understand the output. f <- function(x) substitute(x) g <- function(x) deparse(f(x)) g(1:10) g(x) g(x + y ^ 2 / z + exp(a * sin(b))) Why do they all return "x" ? Especially when g <- function(x) deparse(substitute(x)) returns the "1:10" , "x" , and "x + y ^ 2 / z + exp(a * sin(b))" as expected. 回答1: First, some background information: A promise is an unevaluated argument. A promises comprises of two parts: 1) the code /

Simple substitute of assignment operators of logical ones in JavaScript?

喜你入骨 提交于 2019-12-22 11:22:11
问题 JavaScript has assignment operators corresponding to arithmetic ones: += , -= , *= , /= , %= . JavaScript also has assignment operators corresponding to bitwise ones: <<= , >>= , >>>= , &= , ^= , |= . But it doesn't have assignment operators corresponding to logical ones: ||= , &&= . Then, I can't do things like aVeryLongVariableIdontWantToRepeat ||= 1; In this other question it's explained why JS Java doesn't have such operators. I guess it's the same for JS. But I want to know if there is a

Termination-checking substitution via (monadic) join and fmap

故事扮演 提交于 2019-12-22 11:14:09
问题 I'm using sized types, and have a substitution function for typed terms which termination-checks if I give a definition directly, but not if I factor it via (monadic) join and fmap. {-# OPTIONS --sized-types #-} module Subst where open import Size To show the problem, it's enough to have unit and sums. I have data types of Trie and Term , and I use tries with a codomain of Term inside Term , as part of the elimination form for sums. data Type : Set where 𝟏 : Type _+_ : Type → Type → Type

Change lines that match a pattern in between delimiters using awk

假装没事ソ 提交于 2019-12-22 10:46:04
问题 I have an input file something like this: some line some other line another line start_delimiter interesting stuff more interesting stuff even more interesting stuff end_delimiter possibly more stuff I want to manipulate the lines between start_delimiter and end_delimiter that match a regex pattern and write the results to the input file. For example, add '//' to the beginning of the lines containing the word 'more' (as long as those lines are between the delimiters): some line some other

Bash double process substitution gives bad file descriptor

眉间皱痕 提交于 2019-12-22 04:24:44
问题 When I try to refer to two process substitution pipes in a bash function, only the first one referenced works. The second one gives a "bad file descriptor" error like so: $ foo(){ > cat "$1" > cat "$2" > } $ foo <(echo hi) <(echo bye) hi cat: /dev/fd/62: Bad file descriptor $ It appears that the second pipe is dropped once one is referenced, but a) I cannot seem to confirm this behavior in any documentation and b) I wish it wouldn't. =) Any ideas on what I'm doing wrong? FWIW I'm doing this

How to split text into multiple lines based on a pattern using Vim?

半城伤御伤魂 提交于 2019-12-22 03:24:14
问题 Suppose you have this text: name1 = "John"; age1 = 41; name2 = "Jane"; age2 = 32; name3 = "Mike"; age3 = 36; ... and you want to split each line into two lines to give a result like this: name1 = "John"; age1 = 41; name2 = "Jane"; age2 = 32; name3 = "Mike"; age3 = 36; ... How would you automate this operation? Some notes: I already tried the following method: (1) Select the text in virtual-vode, (2) Execute :'<,'>:norm ^3f r^M ***, but it doesn't work correctly; it splits only half of the

Regular Expression for Conditional Substitution of Angle Brackets

喜夏-厌秋 提交于 2019-12-22 01:16:33
问题 Is it possible to create a single regexp to replace < and > with their entity equivalents in Komodo Edit? s/<|>/<|>/ 回答1: I'm guessing that you may have to convert & to & and so on. If this is the case there's most likely a library or function in whichever language/platform you're using (e.g. in Java check out StringEscapeUtils). Indicate which language you're using and someone here will no doubt point you to something appropriate. 回答2: It is easy in to do this in just about any language

How do I substitute with an evaluated expression in Perl?

冷暖自知 提交于 2019-12-21 09:11:03
问题 There's a file dummy.txt The contents are: 9/0/2010 9/2/2010 10/11/2010 I have to change the month portion (0,2,11) to +1, ie, (1,3,12) I wrote the substitution regex as follows $line =~ s/\/(\d+)\//\/\1+1\//; It's is printing 9/0+1/2010 9/2+1/2010 10/11+1/2010 How to make it add - 3 numerically than perform string concat? 2+1 ?? 回答1: Three changes: You'll have to use the e modifier to allow an expression in the replacement part. To make the replacement globally you should use the g modifier.