Questions tagged [imperative-programming]

Imperative programming is a paradigm of expressing the logic of a computer program or computation by explicitly describing its control flow in terms of statements that change a program state.

From Wikipedia:

In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform.

FAQ:

See also

143 questions
1
vote
1 answer

A double ended queue in OCaml - what's the idea?

I came across this implementation of a deque: type 'a elem = { mutable l1 : 'a elem; mutable l2 : 'a elem; v : 'a option } type 'a queue = { mutable front : 'a elem; mutable back : 'a elem } let init () = let rec g1 = { l1 = g1; l2 = g2; v =…
marmistrz
  • 5,974
  • 10
  • 42
  • 94
1
vote
3 answers

How to manage UI feedback?

Is there an established pattern used to manage user interactions with individual components, such as displaying loader spinners, disabling input fields while a form is saving/loading, etc.? I'm finding myself doing the following in my stores in…
rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123
1
vote
1 answer

abstract syntax tree for imperative languages

I am looking for an abstract syntax tree representation that can be used for common imperative languages (Java, C, python, ruby, etc). I would like this to be as close to source as possible (as opposed to something like LLVM). I found Rose online…
JRR
  • 6,014
  • 6
  • 39
  • 59
1
vote
3 answers

Printing a tree — attempted access of field, but no field with that name was found

I'm am trying to write my first Rust program. I want to print a simple tree on the screen, but I cannot access a value property, it says Error 1 attempted access of field value on type Node, but no field with that name was found …
Alex Zhukovskiy
  • 9,565
  • 11
  • 75
  • 151
1
vote
2 answers

How to declare a reference to a empty stack in OCaml?

perhaps I am being stupid here, so the more general question I want to ask is that how to declare a reference to a empty value of certain type in OCaml. Usually I declare a reference to a custom defined empty value, for example if I have a type type…
Bob Fang
  • 6,963
  • 10
  • 39
  • 72
1
vote
4 answers

Statements and state

Is there any deeper meaning in the fact that the word "statement" starts with the word "state", or is that just a curious coincidence? Note that english is not my native language, so the answer might be obvious to you, but not me ;)
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
1
vote
1 answer

Can Functional Reactive Programming (FRP) be emulated to any degree in an imperative language?

I understand that not every component of Functional Reactive Programming (FRP) may be implemented in most imperative languages purely as a result of how the language has been devised. However, is it possible to use, say, events in C# to achieve a…
1
vote
1 answer

What (precisely) is a command?

Which of the following is most appropriately called a "command," and what should the other be called? changeDirectoryTo changeDirectoryTo /home/peter
goblin GONE
  • 540
  • 3
  • 12
1
vote
2 answers

must the imperative programming paradigm comply with the forward declaration rule?

In a exam in my course of Language Programming was this question: Is the next program valid in a imperative programming? int a = 0; z = a + 2; int z = 3; was not specified or grammar, or syntax, or anything extra. My answer was YES because…
jaundavid
  • 385
  • 1
  • 5
  • 16
1
vote
3 answers

How is Java an 'imperative' programming language and not a 'declarative' one?

Specially in comparison to C/C++ (which are declarative), how is Java imperative?
Moeb
  • 10,527
  • 31
  • 84
  • 110
0
votes
1 answer

Technical term for a constraint on an object in imperative programming

I know there's a technical term for this and for the life of me I can't remember it: When designing a class (or some kind of thing with a functions and data), each call to the object's methods should leave the object's data in a consistent state. …
josh
  • 9,038
  • 8
  • 31
  • 37
0
votes
1 answer

Scheme - Imperative to Functional Programming

I've just started learning Functional Programming (Scheme). But I still have problems thinking "functionally". Something like: func1(int a){ if(a==100) a=0; return func2(a); } There's a state change there, so that's imperative…
eric17859
  • 418
  • 1
  • 5
  • 17
0
votes
2 answers

How to edit reactive form from an observable data in angular imperatively without subscribing to the Observable?

Below is the process I've been using to subscribe and then update a reactive form based on observable data. Maybe there's a way to fix the problem without subscribing to the observable and changing the value. @Component({ selector:…
0
votes
1 answer

What's the expression equivalent of the Assignment statement called?

In imperative programming, using statements, you do stuff like: a = 10 b = a * 2 print a # 20 I have been thinking that the equivalent, in expressions, should be something like this: print with(a=10){with(b=a*2){return b}} This being written in…
0
votes
1 answer

Functional vs imperative (statements): writing this in the most compact way

Looking for the shortest, most elegant wat to write this. I really like option 2. However, i get this error: Argument of type 'boolean[]' is not assignable to parameter of type 'SetStateAction Which makes sense cause in #2 I am…