19,438 questions
0
votes
2
answers
77
views
Comparing an array element to a value throws an error
I'm not sure what I am doing wrong, but when I execute the code below:
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
let length = nums.count-1;
for index1 in 0...length {
...
1
vote
3
answers
91
views
Function to evaluate vector based on time and stops once it reaches a threshold
I have a data frame with three variables ID, year and value. I would like to know how many times the "value" has been larger than a threshold going backwards, from the most recent year to ...
0
votes
1
answer
32
views
How to show a plot only in HTML output in quarto
I wanted to have a dynamic .qmd report which included some mapview plots, but the code would not compile if NOT in HTML format, because it would complain about code generating HTML code for non HTML ...
1
vote
1
answer
23
views
Can you create multiple columns based on the same set of conditions in Polars?
Is it possible to do something like this in Polars? Like do you need a separate when.then.otherwise for each of the 4 new varialbles, or can you use struct to create multiple new variables from one ...
0
votes
0
answers
78
views
Tailwind default styling not being applied when using a custom 'cn' util function with tailwind-merge and clsx
I am using Tailwind V4 and created a custom utility function:
import type { ClassValue } from 'clsx';
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export const cn = (......
0
votes
1
answer
88
views
How can I define an infinite loop condition in the for loop in java?
I was making a program in which user can keep entering numbers till user enters a multiple of 10. So I wanted to created a for loop for that and didn't knew what should be the infinite loop condition ...
0
votes
1
answer
37
views
How to override styling when both conditions are true with Tailwind css
In my Astro component I am using class:list for my tailwind styling.
I have the following situation where both conditions are true, I want isRedColor to be leading. How can I fix that?
<span
...
0
votes
5
answers
145
views
If statement vs. function pointer (performance)
Consider the following:
while(running) {
if(logMode == true)
log();
bar();
}
VS
if (logMode == true)
func_ptr = log;
else
func_ptr = noop; //noop is empty function that ...
1
vote
2
answers
94
views
Dynamically updating and doing math on arrays in Excel
I am dynamically populating an array in Excel from another array in a different sheet based on a criteria and was successful in that but now I wish to auto update the returned total based on another ...
-3
votes
0
answers
28
views
Why does this not work in JS? It always returns Good morning to the console [duplicate]
I am trying to make make it so that it logs 'Good morning!' in the console if the variable hour is between 6 and 12 and 'Good afternoon!' if it is between 13 and 17 and then 'Good night!' if it doesn'...
0
votes
0
answers
36
views
SAS if-then Statement to Python Vectorized Approach - My Values are Not Matching Up
I am trying to replicate some values in a dataset. The original data that I am running my code against for verification purposes has two categories across multiple groups, like so:
grp5
0 ...
1
vote
1
answer
18
views
spss conditional based on macro text
I'm trying to build a simple variable in spss like below but can't figure it out from documentation. In sas, you simply need to put qoutes around your macro to resolve. Can't figure out how in SPSS.
...
1
vote
1
answer
54
views
Swift custom struct: string interpolation not picking up custom description
In the following Swift code:
import Foundation
struct MySet<T: Hashable>: CustomStringConvertible {
let set: Set<T>
}
extension MySet {
var description: String {
return &...
0
votes
1
answer
78
views
RangeError (length): Invalid value: Not in inclusive range 0..5: 6
I am working in quiz app i want when user select answers of all question it should render result screen, it render all question and one can select answers well but after last question instead of ...
-2
votes
2
answers
86
views
What is better: x == False or not x? [duplicate]
There are two different ways to check for a negative condition in python:
if not x:
and
if x == False:
Which is best by standarts of clear code/faster? I saw people using both, but which of this ...