Trying to figure out how to create a “member” function for a list. So far I’ve created this but I’m getting no where near to the correct answer.
spec([system001,hard_drive(50)]).
spec([system002,hard_drive(150)]).
list1(Component):-
spec([Component,X|Y]).
which_system(Component, Component).
which_system(Component):-
list1(Component),
which_system(X, Component).
When I type in which_system(system001).
it works but when i put in which_system(hard_drive(50)).
it wont work at all… I dont know how to make it to find hard_drive(50).
I hope someone can help…
Thanks.
you’re doing it more complex than needed
This works also if you’ll have more components in a system, for instance
spec([system001, hard_drive(50), hard_drive(100)])..will instance S to system001.