SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 210 Weeks Ago, 2 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 11 Dec 2017 My Price 10.00

* Indicates whether a set contains a given element.

Hi. This is about set in functional programming. please see the attachment.

  • object FunctionalSet {

      type Set = Int => Boolean

      /**
       * Indicates whether a set contains a given element.
       */
      def contains(s: Set, elem: Int): Boolean = s(elem)

      /**
       * Returns the set of the one given element.
       */
      def singletonSet(elem: Int): Set = ???

      /**
       * Returns the union of the two given sets,
       * the sets of all elements that are in either `s` or `t`.
       */
      def union(s: Set, t: Set): Set = ???

      /**
       * Returns the intersection of the two given sets,
       * the set of all elements that are both in `s` and `t`.
       */
      def intersect(s: Set, t: Set): Set = ???

      /**
       * Returns the difference of the two given sets,
       * the set of all elements of `s` that are not in `t`.
       */
      def diff(s: Set, t: Set): Set = ???

      /**
       * Returns the subset of `s` for which `p` holds.
       */
      def filter(s: Set, p: Int => Boolean): Set = ???


      /**
       * The bounds for `forall` and `exists` are +/- 1000.
       */
      val bound = 1000

      /**
       * Returns whether all bounded integers within `s` satisfy `p`.
       */
      def forall(s: Set, p: Int => Boolean): Boolean = {
        def iter(a: Int): Boolean = {
          if (???) ???
          else if (???) ???
          else iter(???)
        }
        iter(???)
      }

      /**
       * Returns whether there exists a bounded integer within `s`
       * that satisfies `p`.
       */
      def exists(s: Set, p: Int => Boolean): Boolean = ???

      /**
       * Returns a set transformed by applying `f` to each element of `s`.
       */
      def map(s: Set, f: Int => Int): Set = ???

      /**
       * Displays the contents of a set
       */
      def toString(s: Set): String = {
        val xs = for (i <- -bound to bound if contains(s, i)) yield i
        xs.mkString("{", ",", "}")
      }

      /**
       * Prints the contents of a set on the console.
       */
      def printSet(s: Set) {
        println(toString(s))
      }

    }

Attachments:

Answers

(5)
Status NEW Posted 11 Dec 2017 01:12 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)