Hello! I have checked previous posts on this question, but still have not managed to figure out the issue, as I get the mismatched type error on the function and 3/4 tests failed. My guess is that the error is due to the wrong datatype for the 3rd sensor parameter, but I worked both with symbol and string and got the same error (a screenshot of the code and error is attached - the whole code can be seen inside the spoiler tag).
.f1.checkSensor{[raceTab; lapTab; mySensor] sensorFilter:temp</span><span class='"cm-symbol"'>tyrewind</span><span class='"cm-symbol"'>all!(“temp*”;“tyre*”;“wind*”;“e”); // Get avg benchmark values from historical lap databenchmark:?[lapTab; enlist(in;sensorId</span>;(<span class='"cm-variable"'>sensorFilter</span>;<span class='"cm-keyword"'>enlist</span> <span class='"cm-variable"'>mysensor</span>)); (<span class='"cm-keyword"'>enlist</span> <span class='"cm-symbol"'>sensorId)!enlistsensorId</span>; (<span class='"cm-keyword"'>enlist</span> <span class='"cm-symbol"'>benchmarkValue)!enlist (avg;sensorValue</span>)]; <span class='"cm-variable"'>chk</span><span class='"cm-keyword"'>:</span> <span class='"cm-keyword"'>?</span>[<span class='"cm-variable"'>raceTab</span>; (<span class='"cm-keyword"'>enlist</span>(<span class='"cm-keyword"'>in</span>;<span class='"cm-symbol"'>sensorId;(sensorFilter;enlistmysensor))); (enlistsensorId</span>)<span class='"cm-keyword"'>!</span> <span class='"cm-keyword"'>enlist</span> <span class='"cm-symbol"'>sensorId; avgValue</span><span class='"cm-symbol"'>stdDevValue!((avg;sensorValue</span>);(<span class='"cm-keyword"'>dev</span>;<span class='"cm-symbol"'>sensorValue))]; // Join historical benchmarks to new data and calculate diff chk:updatediffValue:“F”$.Q.f'[5;abs[benchmarkValue-avgValue]] frombenchmarkljchk; // Add flags if difference between old vs new data >1 and if standard deviation>1.5chk:updatediffFlag:?[(diffValue>1);0b;1b],stdFlag:?[(stdDevValue>1.5);0b;1b] fromchk; chk }
Not sure if it’s a typo or not, but the first thing I noticed was your parameters don’t match what is in the function - mySensor vs mysensor.
The next thing I could see was your where clause within your functional statement for benchmark isn’t correct. One way to help you create functional statements is to use parse e.g.
parse “select from table where sym=`ABC”
This will give you the correct structure and you can swap out the values for what you need.
Also ensure you’re using the correct condition, you have used “in” where “like” may be more appropriate.
(The change you make for benchmark will also need to be corrected for chk)
Thank you for your suggestion! I parsed the command as well for the benchmark whereclause statement and retrieved the output on the terminal (screenshot attached). However, I do not understand where I got it wrong - the parse output and the code seem to match (apart from the added enlist keywords at least).
You will need to change it for both benchmark and chk.
If your function statement is still failing, I would advise stepping through the code and ensuring each part of your functional statement is working. You can do this by “nulling” the other parts e.g. to test the where clause:
However, even so, I get the mismatched types error - I truly do not know what to do on this, as I have spent the whole weekend working on this issue (screenshot attached).
Are you running this within the markdown file itself?
I would suggest copying your code into the scratchpad as you’re able to run the code line-by-line and see more clearly what is going wrong.
When you click the “play” button under the code blocks in the markdown file, it is running the entire code block, so you are not able to pinpoint which line is breaking.