$p$-subgroups in $\mathtt{GAP}$ My question is fairly simple. 
Given a finite group $G$ and a prime $p$ dividing the order of $G$, I'd like to ask $\mathtt{GAP}$ to provide two lists:
one with every subgroup of $G$ that is a $p$-group, and one with every
$p$-subgroup lying in a single Sylow.
Ideas?
P.S. I would appreciate an answer in the form of a function accepting two arguments: $G$ and $p$.
 A: While Orat's solution in principle works, it is very inefficient, and I wouldn't want to give it as an example to my students. Instead, let me try to give a more efficient solution, which demonstrates that for computational algebra, you really should know and use both good algorithms, and powerful theorems.
AllPSubgroups := function(G, p)
    local S, c, result;
    S := SylowSubgroup(G, p);
    result := [];
    for c in ConjugacyClassesSubgroups(S) do
        c := ConjugacyClassSubgroups(G, Representative(c));
        Append(result, AsList(c));
    od;
    return Set(result);
end;

For example, on my laptop, for $PSL(3,3)$, this code take 0.34 seconds, while Orat's code takes 8.3 seconds.
The key idea is to exploit the Sylow theorems: Every $p$-subgroup is contained in a Sylow subgroup. Equivalently, if we take a fixed Sylow subgroup $S$, then every $p$-subgroup is conjugate to a subgroup of $S$.
Thus the above code first determines all subgroups of $S$, up to conjugacy. It then takes a representative of each such conjugacy class, and takes all conjugates of that in the original group. Note that we may see some $G$-conjugacy classes twice, since two subgroup $A$, $B$ of $S$ may be conjugate in $G$, but not conjugate in $S$. Hence we invoke Set on the result before returning it.
One can do even better with some further tricks, if one really wants to. But in reality, for most questions one wants to answer, one would not optimize this code, but rather try to modify the question so that it e.g. suffices to know the conjugacy classes of $p$-subgroups, instead of explicitly enumerating the all. E.g. the number of 2-subgroups of $PSL(3,5)$ is 82926, but a Sylow 2-subgroup only has 22 conjugacy classes of subgroups; thus $PSL(3,5)$ has at most 22 conjugacy classes of 2-subgroups. It's much easier to answer questions about these 22 classes than about 82926 groups.
A: For given a group $G$ and a prime $p$, the following would give a solution to your request.
AllPSubgroups := function(G, p)
 return Filtered(AllSubgroups(G), S -> S = SylowSubgroup(S, p));
end;

For given Sylow $p$-subgroup, AllSubgroups would satisfy your request.
