Is there any code in the FriCAS library to generate a power set from a set?
I could not find any so I wrote my own (see below). I probably need
custom code anyway to sort and filter the results.
My problem is that the only way I could work out how to do this is to
customise the list.spad code like this:
https://github.com/martinbaker/fricasAlgTop/blob/topology/list.spad#L295
Is there some way I can make a more standalone version of the following
code?
What I would like to do is replace 'S' with 'Type' but I don't think
that would work would it?

      localPowerSets(j:List(S),filter:List(S)->Boolean): List(List S) ==
        empty? j => list []
        Sm := localPowerSets(rest j,filter)
        Sn: List List S := []
        for x in Sm repeat
          if filter(x) then
            Sn := cons(reverse cons(first j, x),Sn)
        append(Sn, Sm)

      gradeAndOrder(a:List S,b:List S) : Boolean ==
        if #a < #b then return true
        if #a > #b then return false
        for ia in a for ib in b repeat
          if S has OrderedSet then
            if ia < ib then return true
            if ia > ib then return false
        false

      powerSetFiltered(j:List(S),filter:List(S)->Boolean):List List S ==
        map(reverse,sort(gradeAndOrder,localPowerSets(j,filter)))

      powerSet(j:List(S)):List List S ==
        powerSetFiltered(j,(x)+-> true)

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/4321fd4d-ea7d-4aad-9faf-7c34557047e0%40martinb.com.
  • [frica... Martin Baker
    • R... 'Prof. Dr. Johannes Grabmeier' via FriCAS - computer algebra system
    • R... 'Ralf Hemmecke' via FriCAS - computer algebra system
      • ... Kurt Pagani
        • ... 'Ralf Hemmecke' via FriCAS - computer algebra system
          • ... Martin Baker
            • ... Kurt Pagani
              • ... Martin Baker

Reply via email to