quotations

Why is it better to have 100 functions operate on one data structure than 10 functions on 10 data structure

半世苍凉 提交于 2019-12-03 01:08:09
问题 I have seen this quoted in a lot of places: "It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures." —Alan Perlis But I have never seen it explained why this should be true. Is it just the idea that you should try to derive the other 9 data structures from the first to avoid duplicating the data? I feel like I'm missing some context. 回答1: The quote is from Alan Perlis' Epigrams on Programming, which was published in 1982. The meaning of this

Is there any built-in function for human-readable F# quotations?

最后都变了- 提交于 2019-12-01 05:50:30
When quoting <@ 1 + 1 @> I want "1 + 1" instead of "Call (None, Int32 op_Addition[Int32,Int32,Int32](Int32, Int32), [Value (1), Value (1)])" You'll have to write it yourself. See the F# quotations visualizer code as a guide for transforming the quotations abstract syntax tree. I have implemented a quotation decompiler as part of a larger open source project Unquote . It can decompile many simple F# quoted expressions as single-line non-light syntax strings (see the project's home page for a list of decompiler features). For example, > decompile <@ (11 + 3) / 2 = String.length ("hello world"

Converting F# Quotations into LINQ Expressions

大城市里の小女人 提交于 2019-12-01 03:34:13
I can convert a quotation of type Expr<'a -> 'b> to a Linq expression via the following snippet: /// Converts a F# Expression to a LINQ Lambda let toLambda (exp:Expr) = let linq = exp.ToLinqExpression() :?> MethodCallExpression linq.Arguments.[0] :?> LambdaExpression /// Converts a Lambda quotation into a Linq Lamba Expression with 1 parameter let ToLinq (exp : Expr<'a -> 'b>) = let lambda = toLambda exp Expression.Lambda<Func<'a, 'b>>(lambda.Body, lambda.Parameters) Now I want to convert a quotation of type Expr<'a * 'b -> 'c> or maybe even Expr<'a -> 'b -> 'c> to a Linq Lambda Expression of

How do I match a pattern with optional surrounding quotes?

好久不见. 提交于 2019-11-30 11:44:55
How would one write a regex that matches a pattern that can contain quotes, but if it does, must have matching quotes at the beginning and end? "?(pattern)"? Will not work because it will allow patterns that begin with a quote but don't end with one. "(pattern)"|(pattern) Will work, but is repetitive. Is there a better way to do that without repeating the pattern? You can get a solution without repeating by making use of backreferences and conditionals : /^(")?(pattern)(?(1)\1|)$/ Matches: pattern "pattern" Doesn't match: "pattern pattern" This pattern is somewhat complex, however. It first

What is the difference between single, double, and triple quotes in Python? [duplicate]

让人想犯罪 __ 提交于 2019-11-29 11:08:39
This question already has an answer here: Single quotes vs. double quotes in Python [closed] 19 answers In other words, how do I know which one to use? I know when I use strings. I would do string = "This is a string" When would I use ' ' or """ """? '...' and "..." are equivalent. If you have an apostrophe in the string, it is easier to use "..." so you don't have to escape the apostrophe. If you have quotes in the string, it's easier to use '...' so you don't have to escape the quotes. Triple quotes (both varieties, """ and ''' are permitted) allow the string to contain line breaks. These

Difference between double and single quotation marks in fortran?

放肆的年华 提交于 2019-11-27 16:02:43
I'm just starting out on Fortran and am confused with the usage of double vs single quotation marks. They are equivalent. There is no difference in their usage. You can employ this to print one of the quotation characters: print *, "'" print *, '"' prints first ' and then " . Note: You can also use two quote characters in a row to print one: print *, """" print *, '''' prints first " and then ' . Functionally they have no difference. Just try to be consistent about which one you use. If your strings tend to have double quotes in them, use single quotes everywhere; if you use single quotes more

How to insert text with single quotation sql server 2005

╄→гoц情女王★ 提交于 2019-11-27 13:26:53
I want to insert text with single quote Eg john's to table in sql server 2005 database Escape single quote with an additional single as Kirtan pointed out And if you are trying to execute a dynamic sql (which is not a good idea in the first place) via sp_executesql then the below code would work for you sp_executesql N'INSERT INTO SomeTable (SomeColumn) VALUES (''John''''s'')' The answer really depends on how you are doing the INSERT . If you are specifying a SQL literal then you need to use the double-tick approach: -- Direct insert INSERT INTO Table1 (Column1) VALUES ('John''s') -- Using a

Difference between double and single quotation marks in fortran?

我的未来我决定 提交于 2019-11-26 17:23:50
问题 I'm just starting out on Fortran and am confused with the usage of double vs single quotation marks. 回答1: They are equivalent. There is no difference in their usage. You can employ this to print one of the quotation characters: print *, "'" print *, '"' prints first ' and then " . Note: You can also use two quote characters in a row to print one: print *, """" print *, '''' prints first " and then ' . 回答2: Functionally they have no difference. Just try to be consistent about which one you use

How to insert text with single quotation sql server 2005

喜夏-厌秋 提交于 2019-11-26 16:21:10
问题 I want to insert text with single quote Eg john's to table in sql server 2005 database 回答1: Escape single quote with an additional single as Kirtan pointed out And if you are trying to execute a dynamic sql (which is not a good idea in the first place) via sp_executesql then the below code would work for you sp_executesql N'INSERT INTO SomeTable (SomeColumn) VALUES (''John''''s'')' 回答2: The answer really depends on how you are doing the INSERT . If you are specifying a SQL literal then you