Create rules in CLIPS and template person - clips

Template Person
a. Define a template for person, contains full name, children names
b. Define a rule that prints the parents that have more than 3 children
c. Define a rule that print the parent of a certain child
The specified child name will be asserted in a fact called (child-name <name>)
i dont know how to check if the person have more than 3 children

If you have a parent deftemplate with a child-names multislot, then the following pattern will match any parent with more than 3 children:
(parent (childs-names $?names&:(> (length$ ?names) 3)))

Related

What is the meaning of exclamation marks with respect to lists in GraphQL?

What is the difference between the following type definitions in GraphQL?
[Item]
[Item!]
[Item]!
[Item!]!
In which cases can the list be empty?
[Item] means that both the list itself as well as its items can be null.
[Item!] means that the list cannot contain null items, but the list itself can be null.
[Item]! means that the list can contain null items, but the list itself cannot be null.
[Item!]! means that both the list itself as well as its items cannot be null.
In all four cases, the list can be empty.

Inheritance of Attributes on Blocks

I have a parent block (call it Block 1), which has an attribute. Lets call it VoltageIn. The attribute remains empty on this block.
The second block is a child of Block 1 (call it Block 2) and inherits the attribute VoltageIn. Here I want to give a value ( VoltageIn = 230V).
The third block (Block 3) is a child of Block 2 and therefore it inherits the attribute VoltageIn = 230V.
Now, my question is how to handle this with SysML?
The only way to give attributes values, is to create instances of the blocks. Create an instance of Block 2 and assign the value of 230V to VoltageIn. When you then create needed instances of Block 3, it will inherit that value.
Another way of going about this is to assign a default value to VoltageIn of Block 2 to 230V. This is then passed to Block 3. Sometimes you don't want to deal with instances, so this is another option.

What's the usage of org.springframework.data.repository.query.parser.Part?

As you can see in the title , I'd appreciate it if somebody can tell the usage of the Class .
There's a inside enum Type ,how to use it?
public static enum Type {
BETWEEN(2, "IsBetween", "Between"), IS_NOT_NULL(0, "IsNotNull", "NotNull"), IS_NULL(0, "IsNull", "Null"), LESS_THAN(
"IsLessThan", "LessThan"), LESS_THAN_EQUAL("IsLessThanEqual", "LessThanEqual"), GREATER_THAN("IsGreaterThan",
"GreaterThan"), GREATER_THAN_EQUAL("IsGreaterThanEqual", "GreaterThanEqual"), BEFORE("IsBefore", "Before"), AFTER(
"IsAfter", "After"), NOT_LIKE("IsNotLike", "NotLike"), LIKE("IsLike", "Like"), STARTING_WITH("IsStartingWith",
"StartingWith", "StartsWith"), ENDING_WITH("IsEndingWith", "EndingWith", "EndsWith"), NOT_CONTAINING(
"IsNotContaining", "NotContaining", "NotContains"), CONTAINING("IsContaining", "Containing", "Contains"), NOT_IN(
"IsNotIn", "NotIn"), IN("IsIn", "In"), NEAR("IsNear", "Near"), WITHIN("IsWithin", "Within"), REGEX(
"MatchesRegex", "Matches", "Regex"), EXISTS(0, "Exists"), TRUE(0, "IsTrue", "True"), FALSE(0, "IsFalse",
"False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals");
// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, NOT_CONTAINING,
CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
...}
Part is internal to Spring Data. It is not intended to be used by client code. So if you don't implement your own Spring Data Modul you shouldn't use it at all nor anything inside it.
A Part is basically an element of an AST that will probably result in an element of a where clause or equivalent depending on the store in use.
E.g. if you have a method findByNameAndDobBetween(String, Date, Date) parsing the method name will result in two parts. One for the name condition and one for the DOB between condition.
The type enum lists all the different types of conditions that are possible.
The parameters of the elements are the number of method arguments required and (possibly multiple) Strings that identify this type inside a method name.

Error: use of deleted function when adding element to a map in C++

I'm getting a wall of text when I try to compile my code using g++ 11 in a Linux environment. I've tracked the cause of the error to one line of code where I'm trying to add elements to a map. Here's some of the relevant code:
set<Tuple> trash;
Relation garbage(trash, name, scheme_list);
Relations.insert({name, garbage});
Where the Tuple and Scheme classes (scheme_list is of type Scheme) are both simply vector<string>. The Relation class is defined as
public:
Relation(set<Tuple> TUPLES, string NAME, Scheme SCHEMES);
~Relation();
and the Relation constructor is
Relation::Relation(set<Tuple> TUPLES, string NAME, Scheme SCHEMES)
{
Tuples = TUPLES;
Name = NAME;
Schemes = SCHEMES;
}
The intent of the code at the moment is to create an empty set of Tuples, use the existing name in name and the list of schemes in scheme_list to create an instance of class Relation to insert into my map of Relations using the name as the key. Yet when I compile the code, it gives me a gigantic list of "use of deleted function" errors and "Relation::Relation(const Relation&) is implicitly deleted because the default definition would be ill-formed", the latter being the only reference to any of my code given by the compiler. What is causing this error, and why does it only occur when I try to insert elements into a map?

Virtual event multiple binding not working as expected

Here's a simplified version of my code:
from tkinter import *
class MyCustomWidget(Canvas):
def __init__(self, parent = None, **options):
Canvas.__init__(self, parent, options)
self.box = self.create_rectangle(0, 0, 300, 300,fill="blue")
self.bind('<Button-1>', self.on_clicked)
self.tag_bind(self.box, '<B1-Motion>', self.on_clicked)
def on_clicked(self, event):
print( "inner method called")
#now outside this class:
def my_callback(event=None):
print ("outer method called")
root = Tk()
my_widget = MyCustomWidget()
my_widget.event_add('<<my_event>>', '<B1-Motion>', '<Button-1>')
my_widget.bind('<<my_event>>', my_callback)
my_widget.pack()
root.mainloop()
When I run this code and move my mouse (B1-Motion) over the blue box,It calls both the inner and outer method, so I get the following output:
inner method called
outer method called
But when I single click on the blue box (Button-1) it only calls the inner method and the output is:
inner method called
I was expecting both the methods to be called in either cases. Any explanation on why this should behave this way ?
Tkinter won't call two callbacks for the same event. From the official tk documentation:
If more than one binding matches a particular event and they have the same tag, then the most specific binding is chosen and its script is evaluated. The following tests are applied, in order, to determine which of several matching sequences is more specific:
a) an event pattern that specifies a specific button or key is more specific than one that does not;
(b) a longer sequence (in terms of number of events matched) is more specific than a shorter sequence;
(c) if the modifiers specified in one pattern are a subset of the modifiers in another pattern, then the pattern with more modifiers is more specific.
(d) a virtual event whose physical pattern matches the sequence is less specific than the same physical pattern that is not associated with a virtual event.
(e) given a sequence that matches two or more virtual events, one of the virtual events will be chosen, but the order is undefined.
When you click the mouse button, you have more than one binding that matches -- the binding on <<my_event>> and the binding on <1>. The binding for <1> is more specific than the binding on <<my_event>>, so that is the one that is chosen.

Resources