1use melodium_core::*;
2use melodium_macro::{check, mel_function, mel_treatment};
3
4pub mod block;
5
6#[mel_function(
8 generic T (PartialEquality)
9)]
10pub fn contains(vector: Vec<T>, value: T) -> bool {
11 vector.iter().any(|val| val.partial_equality_eq(&value))
12}
13
14#[mel_treatment(
18 generic T (PartialEquality)
19 input value Stream<T>
20 input vec Stream<Vec<T>>
21 output contains Stream<bool>
22)]
23pub async fn contains() {
24 while let (Ok(value), Ok(Value::Vec(vec))) = (value.recv_one().await, vec.recv_one().await) {
25 check!(
26 contains
27 .send_one(vec.iter().any(|val| val.partial_equality_eq(&value)).into())
28 .await
29 )
30 }
31}
32
33#[mel_function(
35 generic T ()
36)]
37pub fn concat(mut first: Vec<T>, mut second: Vec<T>) -> Vec<T> {
38 first.append(&mut second);
39 first
40}
41
42#[mel_treatment(
46 generic T ()
47 input first Stream<Vec<T>>
48 input second Stream<Vec<T>>
49 output concatened Stream<Vec<T>>
50)]
51pub async fn concat() {
52 while let (Ok(Value::Vec(mut first)), Ok(Value::Vec(mut second))) =
53 (first.recv_one().await, second.recv_one().await)
54 {
55 first.append(&mut second);
56 check!(concatened.send_one(Value::Vec(first)).await)
57 }
58}