Skip to main content
1 vote
2 answers
108 views

I am very new at the ST monad, and have reached my wits end in trying to correct the error in the code below. I have a buildChain function, which we can assume works, takes an Int and returns a list ...
Alfy B's user avatar
  • 167
0 votes
1 answer
84 views

I wrote an XUnit test in F# for a function that updates a mutable variable: [<Fact>] let ``UpdatePlayerOneAmountTests`` () = //-- Arrange let input = new StringReader "10" ...
Alex_P's user avatar
  • 3,032
2 votes
1 answer
67 views

I found some really unexpected behavior today using python 3.12.4. I am trying to sort a list of tuples into 2 different lists in a list of lists based on the first number of the tuple. Instead, each ...
seamus's user avatar
  • 29
2 votes
2 answers
112 views

I have encountered a lambda with static variable in the following answer https://stackoverflow.com/a/79631994/2894535 : EXPECT_CALL(my_mock, foo(_)) .WillRepeatedly(InvokeWithoutArgs([](){ ...
Dominik Kaszewski's user avatar
0 votes
0 answers
32 views

MRE: enum MRE_Enum { variant1, variant2, } struct MRE_Struct { dummy1: Vec<MRE_Enum>, dummy2: isize, } // Private functions together impl MRE_Struct { fn foo(&mut self) ...
kesarling's user avatar
  • 2,322
2 votes
4 answers
157 views

I've got a data type that consists of actual data and an id: struct Data { int value; int DataId; }; I've got a collection of these data from which I have to frequently get an element based ...
Oersted's user avatar
  • 3,834
2 votes
0 answers
62 views

I have the below min repro application which is meant to build a graph (tree) from a vec (split string). (It is meant to be part of a larger loop that would modify the graph/tree multiple times.) The ...
Rogus's user avatar
  • 1,290
0 votes
0 answers
24 views

If I wanted to make a nested set: nested_set = {{1, 2, 3}, {6, 4, 5}, {12, 8, 5, 7}} It would give the error: TypeError: unhashable type: 'set' However if I wanted to make a nested list: nested_list =...
frix's user avatar
  • 1
2 votes
0 answers
100 views

I'm learning Rust so getting to grips with mutable and non-mutable. I've copied code from several projects and it works well. This is the ode_solver function for a two-pool compartmental model. My ...
Jim Maas's user avatar
  • 1,759
0 votes
0 answers
37 views

Here is a simple example: [System.Serializable] public struct PlayerData { public string name; public int level; public float health; } [Test] ...
tribbloid's user avatar
  • 3,822
0 votes
1 answer
88 views

I am writing a service, and I want to run a loop forever that checks for some expired objects and removes them if too old. pub struct Obj { expired: NaiveDateTime, } pub struct Maintainer { ...
unsafe_where_true's user avatar
0 votes
1 answer
134 views

Probably this question already has been asked, maybe with different wording, but I couldn't find it. If this gets closed due to this, apologies, but I did try before. In fact, the problem is simple: ...
unsafe_where_true's user avatar
1 vote
1 answer
104 views

This exercice from Rustlings, once corrected, gives: fn move_semantics4() { let mut x = Vec::new(); let y = &mut x; y.push(42); let z = &mut x; z....
overflaw's user avatar
  • 1,136
-1 votes
1 answer
71 views

I have a list of chars. I want to insert a string in between the chars at given index. For that I wrote a function to insert the item (string) in the list in-place. The list inside the function is ...
Suyash Nachankar's user avatar
2 votes
2 answers
142 views

I have import copy class A: _member_a: dict[str, str] _member_b: Callable def set_b(self, func): self._member_b = func def deep_copy(self): return copy.deepcopy(self) I ...
Coolboy's user avatar
  • 51

15 30 50 per page
1
2 3 4 5
82