Welcome to the public discussion channel for the Ceylon programming language (https://ceylon-lang.org)
dependabot[bot] on maven
Bump json-smart from 1.3.1 to 1… (compare)
dependabot[bot] on maven
dependabot[bot] on maven
Bump httpclient from 4.3.2 to 4… (compare)
` public interface Condition {
Condition FALSE = facts -> false;
Boolean evaluate(Fact<?> fact);
default Condition and(Condition other) {
return fact -> this.evaluate(fact) && other.evaluate(fact);
}
default Condition or(Condition other) {
return fact -> this.evaluate(fact) || other.evaluate(fact);
}
default Condition not() {
return fact -> !this.evaluate(fact);
}
} @Test
public void testCondition() {
String str = "A String";
Condition a = fact -> !str.isBlank();
Condition b = fact -> str.contains("A");
a.and(b);
}`
interface Condition<Fact>{
shared static Condition<Fact> falseCondition => object satisfies Condition<Fact> {
shared actual Boolean evaluate(Fact fact) => false;
};
shared static Condition<Data >create<Data>(Boolean(Data) evala)=> object satisfies Condition<Data>{
shared actual Boolean evaluate(Data fact) => evala(fact);
};
shared formal Boolean evaluate(Fact fact);
shared default Condition<Fact> and(Condition<Fact> other)=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => this.evaluate(fact) && other.evaluate(fact);
};
shared default Condition<Fact> or(Condition<Fact> other)=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => this.evaluate(fact) || other.evaluate(fact);
};
shared default Condition<Fact> not=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => !this.evaluate(fact);
};
}
shared test void testConditions(){
value a=Condition.create<String>((String fact) => !fact.empty);
value b=Condition.create<String>((String fact)=> fact.contains("A"));
value result=a.and(b).evaluate("A string");
assert(result);
}
Condition.create
as top level function so You don't have to prefix it
and
and or
but function reference like in create so it would be: interface Condition<Fact>{
shared static Condition<Fact> falseCondition => object satisfies Condition<Fact> {
shared actual Boolean evaluate(Fact fact) => false;
};
shared static Condition<Data >create<Data>(Boolean(Data) evala)=> object satisfies Condition<Data>{
shared actual Boolean evaluate(Data fact) => evala(fact);
};
shared formal Boolean evaluate(Fact fact);
shared default Condition<Fact> and(Boolean(Fact) other)=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => this.evaluate(fact) && other(fact);
};
shared default Condition<Fact> or(Boolean(Fact) other)=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => this.evaluate(fact) || other(fact);
};
shared default Condition<Fact> not=> object satisfies Condition<Fact>{
shared actual Boolean evaluate(Fact fact) => !this.evaluate(fact);
};
}
shared test void testConditions(){
value a=Condition.create<String>((String fact) => !fact.empty);
value b=((String fact)=> fact.contains("A"));
value result=a.and(b).evaluate("A string");
assert(result);
}
Does ceylon-1.3.3 support static
interface member? I'm frequently getting following exception:
Ceylon backend error: method does not override or implement a method from a supertype
Some classes are missing from the generated module archives, probably because of an error in the Java backend compilation.
This is the case both from CLI and IDE-eclipse(oxygen) & IntelliJ-2017.2. JDK is 1.8.0_202 on Windows 7
Hello once again, everyone! I hope you all have been doing well!
To anyone who might still frequent this channel: I don’t know if it’s of interest to anyone, but I wanted to mention that I decided to spend some time today generating a native image for my old solitaire game with GraalVM. It took me a while to figure it out, but it seems everything is working fine now!
I have been really looking forward to start playing around with Ceylon again! I don’t care if the project has been going slow lately, I just want to be able to actually enjoy a programming language again for once! And Ceylon is such a nice language, I feel like it’s difficult to not enjoy it. :blush:
I wish a great end of year to whomever here cares about the Gregorian calendar! :tada: All the best!
unxz < solitaire.xz > solitaire
chmod +x solitaire
./solitaire