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
2
votes
3 answers
Writing a unary function chainer, TypeError on codewars but no error on repl.it?
I worked on this problem on code wars for a little while and used repl.it to test it out. It's a simple unary function chainer, but it only works on repl.it, while codewars will give me a TypeError when given this code:
function chained(functions)…

Petrell Vereen
- 21
- 1
2
votes
3 answers
Order of goals(statements) in Prolog rules
I began to study Prolog recently and faced one strange problem.
Here you can see a code example (I use SWI-Prolog 7.2.3) which gives a tree of relationships and my solution of 2 tasks.
/* File: ancestors.pl
Author: Dave Robertson
Purpose:…

Ilya Muradyan
- 387
- 2
- 13
2
votes
4 answers
What, if any, is wrong with this approach to declarative I/O
I'm not sure exactly how much this falls under 'programming' opposed to 'program language design'. But the issue is this:
Say, for sake of simplicity we have two 'special' lists/arrays/vectors/whatever we just call 'ports' for simplicity, one called…

Zorf
- 6,334
- 2
- 29
- 24
2
votes
2 answers
Merge lists of lists in prolog
I would like to perform something like:
merge([[[],[],[],[t1]],[[],[],[],[t2,t3]]], X).
where X would return as: [[],[],[],[t1,t2,t3]].
But I have tried everything to my prolog knowledge and came up with nothing.
Any hints?
Imagine it…

voluminat0
- 866
- 2
- 11
- 21
2
votes
1 answer
how to model a declarative language
I am using puppet. And puppet is a declarative language and I need to model my code.
My question is what are the modeling languages for declarative programming languages?
In other words: we use uml to model imperative languages but uml is not…

user3738655
- 25
- 2
2
votes
2 answers
Learning recursion in Prolog
I have a basic understanding of how recursion works in Prolog. I am finding it difficult to think in declarative paradigm. Could you suggest some learning resources(with solved examples) for writing recursive predicates?

dev
- 2,474
- 7
- 29
- 47
1
vote
0 answers
Recommendation for Android only with Flutter or Jetpack Compose
If I’m looking to do Android only development, not concerned with deploying an app to the iOS App Store. It looks like this is possible in Flutter by enabling this flag, —no-enable-ios, here in the docs.
Would it best to go about a new app in…

Petesta
- 1,623
- 3
- 19
- 29
1
vote
0 answers
How we can get animation complete listner for motion layout in jetpack compose?
Here is my question how do I get a complete animation listener for motion layout in jetpack compose?
My purpose is to do that I want to trigger another animation after completing the motion layout animation.
And another question is how to do…

Bhavin Vala
- 41
- 2
1
vote
2 answers
How can I get an object by ID using observables (declarative pattern)
I am attempting to make my application more reactive/declarative vs procedural & having a really hard time trying to grasp not passing arguments to/from my service.
My url looks like this:…

Damon
- 4,151
- 13
- 52
- 108
1
vote
1 answer
How to describe a language that ignores implimentation and only describes behavior
I wanted to ask how people would describe a programming language that basically describes the behavior of a program rather than the implementation - ie. a language that ignores implementation issues (e.g. only having a single class or function where…

B T
- 57,525
- 34
- 189
- 207
1
vote
1 answer
QuickSort applied to a list of tuples (Int,[Int]) in Haskell
Good afternoon,
I'm a newb to Haskell, and I'm trying to adapt a QuickSort algorithm I made to sort lists of 'Int' with a list of tuples, but I quite can't figure out how to bind the tail to 'a' to make it work as I need it to, or if it's possible…

ViniV
- 39
- 5
1
vote
2 answers
declarative loop vs imperative loop
I am trying to switch my programming style to declarative from imperative, but there is some concept that is bugging me like the performance when it comes to the loop. For example, I have an original DATA, and after manipulating it I wish to get 3…

dummy
- 21
- 6
1
vote
2 answers
How to sum the elements of two 2d arrays?
I'm trying to add the elements of two two-dimensional arrays with each other, by using the java stream API.
I managed the problem with a one-dimensional array, but I don't know how to proceed further with a two-dimensional array.
Here is the code to…

Kkh
- 21
- 4
1
vote
2 answers
Type Error in Alloy using Double In Statement
I am trying to write a predicate that will make all Bananas and Fresh Apples expensive. I am able to achieve one of the conditions but never both. I'm very new to using Alloy, any help would be very much appreciated.
Below is my code, the error is…

M5RKED
- 73
- 1
- 16
1
vote
4 answers
javascript functional / declarative version of for loop (with this example)?
Having this code
const myMagic = (one, two, three, four) => `this is ${one} and ${two} and ${three} and ${four} as usual`
const txt = 'HELLO&ho&hy&hu&hq&HELLO&ho&hy&hu&hq&HELLO&ho&hy&hu&hq&HELLO&ho&hy&hu&hq&hx'
const fragments =…

GWorking
- 4,011
- 10
- 49
- 90