declarative

Are the implementation details of declarative languages inherently imperative

╄→гoц情女王★ 提交于 2019-12-06 03:47:06
问题 I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming. What I was wondering is how are the primitive operators & functions implemented, are declarative languages constructed from imperative operators & functions. Cheers AWC 回答1: If I understand your question correctly, I don't think that is a hard and fast rule. For example, you can use a functional language like Lisp, to create an interpreter for itself

SQLAlchemy custom query column

自闭症网瘾萝莉.ら 提交于 2019-12-06 01:54:04
I have a declarative table defined like this: class Transaction(Base): __tablename__ = "transactions" id = Column(Integer, primary_key=True) account_id = Column(Integer) transfer_account_id = Column(Integer) amount = Column(Numeric(12, 2)) ... The query should be: SELECT id, (CASE WHEN transfer_account_id=1 THEN -amount ELSE amount) AS amount FROM transactions WHERE account_id = 1 OR transfer_account_id = 1 My code is: query = Transaction.query.filter_by(account_id=1, transfer_account_id=1) query = query.add_column(case(...).label("amount")) But it doesn't replace the amount column. Been

Jenkins declarative pipeline: What workspace is associated with a stage when the agent is set only for the pipeline?

筅森魡賤 提交于 2019-12-06 01:44:57
问题 Here is an example of declarative pipeline where the agent is set for the pipeline but not set in the individual stages: pipeline { agent { node { label 'linux' } } stages { stage('Checkout') { steps { checkout scm } } stage('Build') { steps { sh 'make' } } } } Documentation I've found about scripted pipeline makes it clear that a single workspace will be used within a single node block but multiple node blocks might be allocated multiple workspaces, therefore it is necessary to stash between

Dictionary of tags in declarative SQLAlchemy?

左心房为你撑大大i 提交于 2019-12-05 08:30:49
I am working on a quite large code base that has been implemented using sqlalchemy.ext.declarative , and I need to add a dict-like property to one of the classes. What I need is the same as in this question , but in a declarative fashion. Can anyone with more knowledge in SQLAlchemy give me an example? Thanks in advance... Declarative is just another way of defining things. Virtually you end up with the exact same environment than if you used separated mapping. Since I answered the other question, I'll try this one as well. Hope it gives more upvotes ;) Well, first we define the classes from

Sqlalchemy dynamically create table and mapped class

有些话、适合烂在心里 提交于 2019-12-05 07:58:25
问题 Given a set of column names and their types, the goal is to to instantiate a table and the corresponding mapped class. It is related to question posted here: Dynamic Class Creation in SQLAlchemy. So far I have the following: table = Table(tbl, metadata, *(Column(col, ctype, primary_key=pk, index=idx) for col, ctype, pk, idx in zip(attrs, types, primary_keys, indexes)) ) This creates the table object. Now I need to create the corresponding class. mydict={'__tablename__':tbl} cls = type(cls

Are the implementation details of declarative languages inherently imperative

大兔子大兔子 提交于 2019-12-04 07:26:01
I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming. What I was wondering is how are the primitive operators & functions implemented, are declarative languages constructed from imperative operators & functions. Cheers AWC If I understand your question correctly, I don't think that is a hard and fast rule. For example, you can use a functional language like Lisp, to create an interpreter for itself. In this case, the implementation details are implemented in a functional manner (because Lisp is a

How to convert prolog parse tree back to a logical sentence

天大地大妈咪最大 提交于 2019-12-04 07:24:35
I managed to build the parse tree for given sentence and here it is, for the sentence: "The man went home." T = s(np(det(the), n(man)), vp(v(went), np(n(home)))) 1) How to use phrase/2 on this? How to translate a sentence in a logical language using prolog? - is similar to what I need, but it's solution doesn't work on me. 2)I want to map this with grammar pattern and get the words tag. Det=the , N(Subject)=man , V=went , N(Object)=home Is there a way to map this tree with given set tree structures and identify the grammar. how can I use parse tree to identify Subject, verb, object, the

Jenkins declarative pipeline: What workspace is associated with a stage when the agent is set only for the pipeline?

ぐ巨炮叔叔 提交于 2019-12-04 06:37:34
Here is an example of declarative pipeline where the agent is set for the pipeline but not set in the individual stages: pipeline { agent { node { label 'linux' } } stages { stage('Checkout') { steps { checkout scm } } stage('Build') { steps { sh 'make' } } } } Documentation I've found about scripted pipeline makes it clear that a single workspace will be used within a single node block but multiple node blocks might be allocated multiple workspaces, therefore it is necessary to stash between those steps, use the External Workspace Plugin, etc. if you want to be sure of what's in the workspace

What is build-by-convention in Gradle deep explanation?

…衆ロ難τιáo~ 提交于 2019-12-03 16:27:12
问题 The Gradle User Guide often mentions that Gradle is declarative and uses build-by-convention . What does this mean? From what I understand it means that, for example, in java plugin there are conventions like source must be in src/main/java ,tests must be in src/main/test , resources in src/main/resources , ready jars in build/libs and so on. However, Gradle does not oblige you to use these conventions and you can change them if you want. But with the second concept, I have a bigger problem

Elegant examples of xslt?

一个人想着一个人 提交于 2019-12-03 16:16:27
After a long learning loop via XAML, I've returned to HTML and javascript, and realised that the concept of declarative code - in terms of rules for transformation - is an incredibly powerful concept. Despite its surfeit of syntax, XSLT processing of XML is the keystone of declarative transformation programming. I have, however, always found it hard to understand how XSLT would be used for everyday tasks (with XML). What are some good examples of XSLT elegantly solving a programming problem, outside of generating HTML? I'm guessing it's good at graph transformation and data reprocessing...