Questions tagged [mutable]

A mutable can be modified after it is created.

A mutable can be modified after it is created. It is a keyword in functional programming opposite to immutable.

Related tags:

1184 questions
0
votes
1 answer

Edit a variable without editing the origin

I need to copy a variable and make changes to it. I've alredy seen this, but i want the oposite. In this code i need the returned tuple to be two different lists, not the same. def getIPRange(self): group = [0, self.getJoinedNetworks() - 1] …
gcq
  • 937
  • 3
  • 13
  • 19
0
votes
2 answers

Attempt to mutate immutable object error

My code crashes at this line: [(NSMutableString *)string replaceCharactersInRange:range withString:@""]; with the error attempt to mutate immutable object. How is this happening and how do i fix it?
Alex
  • 451
  • 5
  • 13
0
votes
2 answers

Add code to block dynamically

I'm pretty new to using blocks. I'm wondering if there is a way to add code dynamically to a block? A mutable block if you will.
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
0
votes
2 answers

Modifying an instance of string

I have a string: str="D\\projects\\myown\\java" I assigned this string to two variables like: str1=str str2=str After I did the below operation: idgb1=str1.gsub!("\\","_") I get str1 as D_projects_myown_java and str2 is the same. why does this…
ѕтƒ
  • 3,547
  • 10
  • 47
  • 78
0
votes
1 answer

Extracting elements from STArray (similar to unzipping)

I'm having a slight problem implementing a particle based fluid simulation in Haskell for a programming competition. I currently have an array of particles that gets modified at each simulation step. Each particle is a tuple of 2 vectors: position…
0
votes
2 answers

mutable field with overloaded assignment operator

I have a C++ class field that is declared mutable. When it was of type double, I could modify it in a const method with no problem. But when I switched its type to a class in which operator= is overloaded, I got the error that this overloaded…
user410315
  • 696
  • 5
  • 8
0
votes
2 answers

Modifying a hash with multiple occurrences

a is a hash. s is an array where I want to push the hash a iteratively. The idea is to retain the value of each iteratively pushed hash independently. Here is what I tried. a = {:a=> 1, :b=>2} s = [] s << a s << a # => [{:b=>2, :a=>1}, {:b=>2,…
Saurajeet
  • 1,088
  • 2
  • 8
  • 10
0
votes
2 answers

Priority Queue and Mutability

>>> import Queue >>> q = Queue.PriorityQueue() >>> a = (1, {'item': 'value'}) >>> q.put(a) >>> q.queue [(1, {'item': 'value'})] >>> a[1]['count'] = 1 >>> q.queue [(1, {'count': 1, 'item': 'value'})] >>> q.get() (1, {'count': 1, 'item':…
Bharathwaaj
  • 2,627
  • 2
  • 22
  • 35
0
votes
1 answer

FP modelling - Mutability issue

I am about to start a simulation/modelling project. Let's say I have a component of type A, characterised by a set of data (a parameter like temperature or pressure,a PDE and some boundary conditions,etc.) and a component of type B, characterised by…
0
votes
4 answers

How to change one item in dictionary

I need a function to change one item in composite dictionary. I've tried something like.. def SetItem(keys, value): item = self.dict for key in keys: item = item[key] item = value and SetItem(['key1', 'key2'],…
Meloun
  • 13,601
  • 17
  • 64
  • 93
0
votes
3 answers

Problems drawing a bitmap on a layout

I create the Layout programatically in onCreate: new Handler().postDelayed(new Runnable() { @Override public void run() { myView = new MyView(SketchActivity.this, layout.getWidth(), layout.getHeight()); …
rosu alin
  • 5,674
  • 11
  • 69
  • 150
0
votes
2 answers

Generate a list of distinct empty mutables

I need to initialize a list of defaultdicts. If they were, say, strings, this would be tidy: list_of_dds = [string] * n …but for mutables, you get right into a mess with that approach: >>> x=[defaultdict(list)] * 3 >>> x[0]['foo'] = 'bar' >>>…
kojiro
  • 74,557
  • 19
  • 143
  • 201
0
votes
1 answer

Can someone explain these programming terms: reference semantics, non-linear mutable state?

Can you explain these terms for me: reference semantics and value semantics (and how they contrast) and non-linear mutable state. They are mentioned in the comments to the book review in this link http://lambda-the-ultimate.org/node/2849 The book is…
Ali
  • 21
  • 3
0
votes
1 answer

F# Mutable Array & Basic Classes Not Behaving As Expected in Unit Testing

I am trying to learn F# and have started to play around with a couple of simple classes, but these are not quite behaving as expected. I must be misunderstanding some simple fundamental. Apologies if this question is too basic, but any help would…
posfr
  • 11
  • 2
0
votes
1 answer

Draw on Bitmap in dependency to screen size

I am working with two other people on a Android project (2.2) for my studies. We want to show maps of some university buildings so you canf find rooms easier. We use a custom ImageView (TouchImageView). I make the bitmap mutable with plant =…
Dominik
  • 360
  • 1
  • 5
  • 16