Questions tagged [mutation]

Mutation refers to a genetic operator used to maintain genetic diversity from one generation of a population to the next. For javascript DOM, use [mutation-observers]. For Java mutators, use [mutators]. For object mutability in general, use [mutability].

430 questions
15
votes
3 answers

Replace array item with another one without mutating state

This is how example of my state looks: const INITIAL_STATE = { contents: [ {}, {}, {}, etc.. ], meta: {} } I need to be able and somehow replace an item inside contents array knowing its index, I have tried: return { ...state, …
Ilja
  • 35,872
  • 66
  • 218
  • 401
15
votes
6 answers

Remove data from nested objects without mutating

Is there any elegant way of removing an object from an array which is part of an array? I have been working with React and Redux for a while now but get stuck several hours everytime I have to remove or insert data without mutating the state. The…
Daniel Storch
  • 907
  • 2
  • 10
  • 24
15
votes
5 answers

applying crossover and mutation to a graph (genetic algorithm)

I'm playing arround with a Genetic Algorithm in which I want to evolve graphs. Do you know a way to apply crossover and mutation when the chromosomes are graphs? Or am I missing a coding for the graphs that let me apply "regular" crossover and…
Manuel Araoz
  • 14,795
  • 21
  • 67
  • 91
14
votes
0 answers

How to calculate the number of mutants in a quite simple Fortran-77 Program

Next week I will make a presentation about mutation test in my class. The professor give me the paper An Experimental Determination of Sufficient Mutant Operators, written by A. Jefferson Offutt et.al. From the paper, I can get a conclusion that the…
machinarium
  • 581
  • 5
  • 16
10
votes
3 answers

Why do we need to avoid mutations while coding? What is a mutation?

Why is the second code (the one with the stream) a better solution than the first? First : public static void main(String [] args) { List values = Arrays.asList(1,2,3,4,5,6); int total = 0; for(int e : values) { total += e *…
codeme
  • 591
  • 1
  • 9
  • 26
9
votes
2 answers

How to pass variables in mutation graphQL Playground?

I am using apollo express server 2.0. And I am trying to execute mutation in the graphql playground. Here is the mutation I have attached a screenshot with another screenshot of a variable. I am getting the following error when I am trying to…
Piyush Bansal
  • 1,219
  • 1
  • 12
  • 34
9
votes
1 answer

PTTest is failing and not generating mutation coverage

I want to generate mutation test coverage. I am doing POC on PI Test but it is not taking my test classes and failing. I have configured PTTest plugin in pom.xml. I checked the target class package name and target test class package name are correct…
Prithvipal Singh
  • 462
  • 2
  • 8
  • 20
8
votes
3 answers

Python difference between mutating and re-assigning a list ( _list = and _list[:] = )

So I frequently write code following a pattern like this: _list = list(range(10)) # Or whatever _list = [some_function(x) for x in _list] _list = [some_other_function(x) for x in _list] etc I saw now on a different question a comment that explained…
Neil
  • 2,116
  • 2
  • 12
  • 28
8
votes
1 answer

Why doesn't MutationObserver code run on Chrome 30?

From http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers I got the following code: var insertedNodes = []; var observer = new WebKitMutationObserver(function(mutations) { alert('run'); …
weilou
  • 3,869
  • 8
  • 37
  • 56
8
votes
1 answer

How do I save and change the value of a variable in OCaml?

This may be a very newbie question, but I didn't find the answer. I need to store, for example a list and later replace it with another, under the same pointer.
EBM
  • 939
  • 2
  • 10
  • 18
7
votes
1 answer

mutate() got multiple values for argument 'name'

I want to query createThemes to my graphql. My graphql query is: mutation{ createTheme(name: "qwe"){ theme{ id } } } So it errors: mutate() got multiple values for argument 'name' Can you solve and explain why its printing such…
user10763646
7
votes
2 answers

What are the ways to avoid object mutation in Dart-lang?

If we take the following snippet as an example: main() { List array = [1, 2, 3, 4]; List newArray = change(array); print(array); // [99, 2, 3, 4] print(newArray); // [99, 2, 3, 4] print(newArray == array); //…
7
votes
2 answers

Why don't lazy languages support mutation?

I'm studying programming language theory and I can't figure out a solid reason why lazy languages don't have mutation. Anyone know the reason?
forellana
  • 877
  • 1
  • 8
  • 17
6
votes
3 answers

How can a genetic algorithm optimize a neural network's weights without knowing the search volume?

I've implemented a genetic algorithm trained neural network with a mutation operator like so: def mutation(chromosome, mutation_rate): for gene in chromosome: if random.uniform(0.00, 1.00) <= mutation_rate: gene = random.uniform(-1.00,…
gator
  • 3,225
  • 6
  • 32
  • 66
6
votes
2 answers

Vuex/Vuejs: accessing localStorage within vuex store

I am using localStorage to set and get items, which is placed within my javascript code in a .vue file. However, I would like to somehow access that storage and place it within my Vuex store section which is in another file, most preferably within…
Aadil Hafesji
  • 311
  • 1
  • 6
  • 20
1
2 3
28 29