Declarative programming is a paradigm of expressing the logic of a computer program or computation without explicit describing its control flow.
Questions tagged [declarative-programming]
78 questions
3
votes
0 answers
What are the differences between Constraint programming and Logic programming?
I am aware that Constraint programming and Logic programming are sub-paradigms of Declarative programming. But I couldn't find a difference between them. What is the difference between them? Could you please provide some examples?

UdhanIsuranga
- 131
- 1
- 8
3
votes
1 answer
Feedback, resources, and information for declarative programming language
I've been thinking of some concepts underlying a new language. It was kind of a toy at first, but now I'm wondering whether it could really mean something. I'm posting this question to Stack Overflow to see if it's been done before, and if I can…

rovaughn
- 1,213
- 15
- 24
3
votes
3 answers
Deep Reverse in PROLOG - Lists
Hey I'm trying to create a predicate for the generating of a deep reverse on nested Lists in PROLOG.
Currently I got this predicate
reverse(L,A) :- rev(L,[], A).
rev([],A,A).
rev([H|L],R,A) :- rev(L,[H|R],A).
The result looks like…

CrimsonKing
- 95
- 10
3
votes
5 answers
Prolog: I am stuck in an imperative mindset
I am taking a class on programming paradigms. Currently we are learning Prolog, and I am stuck in a different paradigm. One of the functions I'm trying to convert from imperative is a relatively simple function.
foo(A,B,C)
if(A > B) C is 1
…

Cullen S
- 155
- 1
- 3
- 10
3
votes
3 answers
Prolog 'is/2' predicate implementation
How is the 'is/2' Prolog predicate implemented?
I know that
X is 3*4
is equivalent with
is(X, 3*4)
But is the predicate implemented using imperative programming?
In other words, is the implementation equivalent with the following C…

bsky
- 19,326
- 49
- 155
- 270
2
votes
1 answer
What is the difference between declarative and imperative programming in flutter?
Recently, I was searching for a way to enhance navigating between screens in my Flutter apps. and I found new programming concepts for me (declarative and imperative programming). I need to know more about the declarative and imperative paradigms…

Abdelrahman Nasser
- 33
- 6
2
votes
2 answers
Functional programming: Declarative vs imperative
Functional programming insists on telling what to do, rather than how to do.
For example,Scala's collections library has methods like filter, map etc. These methods enable developers to get rid of traditional for loops, and hence so called…

Mandroid
- 6,200
- 12
- 64
- 134
2
votes
2 answers
Java Stream Grouping by multiple fields individually in declarative way in single loop
I googled for it but I mostly found cases for grouping by aggregated fields or on to alter response of stream but not the scenario below:
I have a class User with fields category and marketingChannel.
I have to write a method in the declarative…

FarazAhmed
- 43
- 6
2
votes
1 answer
Why re-constructing view hierarchy is affordable in declarative UI frameworks like Flutter?
I am reading Flutter's official documentation on state management and in this page it says:
For example, in Flutter it’s okay to rebuild parts of your UI from scratch instead of modifying it. Flutter is fast enough to do that, even on every frame…

Perqin
- 755
- 10
- 27
2
votes
2 answers
Find if a string from one Set is substring of string from another Set using declarative style?
I have two Sets of strings, I need to find if a string is substring of any string from another Set. Below is the equivalent code in imperative style.
boolean elementContains() {
Set set1 = Set.of("abc","xyz","mnop");
Set…

Govinda Sakhare
- 5,009
- 6
- 33
- 74
2
votes
1 answer
Python declarative loop refactor (need access multiple elements)
Hi I have this piece of code and trying to refactor it to be declarative. But AFAIK, all declarative methods like map() reduce() filter() will loop through each element of the container, not a few like this
def arrayCheck(nums):
# Note: iterate…

Patton
- 125
- 1
- 11
2
votes
1 answer
How do I tell tell a child element in React to seek its video element?
I have a simple React app with a video player and chart displaying data about the video. Both are in their own components at the top level:
class App extends Component {
...
render() {
return (
…

Andrew Schwartz
- 4,440
- 3
- 25
- 58
2
votes
1 answer
Interning strings in declarative programming
The following scenario shows an abstraction that seems to me to be impossible to implement declaratively.
Suppose that I want to create a Symbol object which allows you to create objects with strings that can be compared, like Symbol.for() in…

while1fork
- 374
- 4
- 15
2
votes
1 answer
How do program in a declarative style?
I am enjoying the puppet declarative model. I'd like to try to incorporate more of this into my code.
I program in python currently, however, and I tend to think imperatively while doing so. It's just like my problem with graphic design: I know…

chiggsy
- 8,153
- 5
- 33
- 43
2
votes
2 answers
serializing annotations as well as fields to JSON
I have a spring boot app, and I want to send DTO validation constraints as well as field value to the client.
Having DTO
class PetDTO {
@Length(min=5, max=15)
String name;
}
where name happens to be 'Leviathan', should result in this JSON being…

user690954
- 313
- 2
- 9