'Prolog: show a list contained within a list

I currently have the following facts defined in a Prolog program:

hobbies([jarrod, [gaming, running, boxing]]).
hobbies([james, [programming, gaming, drawing]]).

What query could display a list of jarrod's hobbies? (i.e. [gaming, running, boxing])



Solution 1:[1]

@false is correct:

hobbies([jarrod, Hobbies]).

it unifies hobbies against all the facts, and then only gets the ones where the first element of the list is jarrod. Then it unifies Hobbies with the list of hobbies.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bchurchill