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
0
votes
2 answers

Why do I get a type unit when I want to concatenate the element of the array with an empty list?

I am trying to make a list out of a given array and in my code it returns an empty list. I want to know why this is impossible to do with list. Is it because we are supposed to return something in the third line and the concatenation is not "saved"…
0
votes
1 answer

How can I generate imperative non-OOP python code from UML/SysML model?

I want to generate python code based on UML/SysML. The coding is mainly imperative - calling functions that deliver results, switch states and some main part. How can I create some simple main program, that contains my logic (again primitive: some…
DoctorG
  • 9
  • 2
0
votes
3 answers

Why functional style search acts faster, then imperative in Java

I’m trying to figure out , why compiler looks through the collection using functional style swiftly then imperative. Here is the simple example where functional search goes first and takes 9.5 sec to deal with it , while imperative follows right…
0
votes
1 answer

Link between models of computation, computer system architectures and programming paradigms

I have been reading about these topics for a while and may have understood something. But I am confused with some connections: i. Turing Machine (RAM model to be exact) & Imperative Programming Lambda Calculus & Functional Programming ii. Von Nueman…
0
votes
2 answers

How to modify last element of a generator in python?

I have a generator and I want to modify the last element of the generator. I want to replace the last element with another element. I know how to retrieve the last element, but not how to modify it. What would be the best way to approach this? For…
0
votes
3 answers

Pointer to a record in OCaml

I am implementing binary search trees in OCaml, trying to use as much imperative programming as possible. I have the following data type: type tKey = Key of int;; type tBST = Null | Pos of node ref and node = {mutable key : tKey;…
deko
  • 463
  • 1
  • 6
  • 17
0
votes
0 answers

Can pure imperative programming incorporate functions

As the question suggests, if a program should be written in a purely imperative style (even if the programming language is an amalgamated language like PHP or Python which support other paradigms like OOP), should the program incooperate built in…
Liam Fell
  • 1,308
  • 3
  • 21
  • 39
0
votes
1 answer

Are data races intrinsic to imperative programming and an obstacle for parallel computing?

I don't study this area of computing to be honest. Actually my references is some web and academic articles then I'm insecure but curious about some concepts of parallel computing. I've formulated two sentences and would like to validate it. First…
0
votes
1 answer

Better readability and simplicity versus higher complicity and speed in programming, what to chose?

Solving my homework for Informatics at University, I always find different ways to solve the same problem. One way is the fastest(execution time) but the longest and more complex. And the other is way easier to realize, falls short in execution…
0
votes
2 answers

Possible OCaml code generation bug

The following self contained code highlights a problem in OCaml, possibly with the code generation. Array x has connectivity information for nodes in [0..9]. Function init_graph originally constructed explicit arrays of incoming nodes for every…
0
votes
1 answer

What does it mean to convert a function to a table look up?

In this video titled Don't fear the monad, between 05:02 and 06:05, Brian Beckman says: Every imperative programmer goes through this phase of learning that functions can be replaced with table look-ups. Often, you do this for performance. You…
0
votes
0 answers

What does it mean to change the program's state in imperative programming?

What does the following definition of imperative programming mean? Imperative programming is a programming paradigm that uses statements that change a program's state. What is a program state, and how do you change it?
Uros de Selbi
  • 45
  • 3
  • 10
0
votes
1 answer

Declarative / Imperative Cross Over

I'm looking for a way to gain reference to a class that was instanciated via XML, but I need reference to it in imperative code. I usually do this via the datacontext of the control, but in this case, the user control does not have declaritive…
0
votes
3 answers

Understanding Functional Programming

I hope I am contemplating my question correctly. As far as my understanding, imperative programming (to the very brief) is based on mutation, control structures such as loops and assignments. While i was following a course about functional…
Srini
  • 3,334
  • 6
  • 29
  • 64
0
votes
2 answers

Does anyone else think instance variables are problematic in database-backed applications?

It occurs to me that state control in languages like C# is not well supported. By this, I mean, it is left upto the programmer to manage the state of in-memory objects. A common use-case is that instance variables in the domain-model are copies of…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331