Rosetta Code/Find unimplemented tasks: Difference between revisions
Content deleted Content added
m →{{header|Python}}: added libheaders (not sure if it's ok) |
Add Scala solution |
||
Line 1,851: | Line 1,851: | ||
<tr style='white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word'><td>Zebra puzzle</td><td>Zeckendorf number representation</td></tr></table> |
<tr style='white-space: pre-wrap;white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word'><td>Zebra puzzle</td><td>Zeckendorf number representation</td></tr></table> |
||
Total unImplemented Tasks:177<br /> |
Total unImplemented Tasks:177<br /> |
||
=={{header|Scala}}== |
|||
Add to `build.sbt` |
|||
libraryDependencies ++= Seq( |
|||
"org.json4s"%%"json4s-native"%"3.6.0", |
|||
"com.softwaremill.sttp"%%"core"%"1.5.11", |
|||
"com.softwaremill.sttp"%%"json4s"%"1.5.11") |
|||
<lang scala> |
|||
import com.softwaremill.sttp.json4s._ |
|||
import com.softwaremill.sttp.quick._ |
|||
implicit val serialization = org.json4s.native.Serialization |
|||
import org.json4s.DefaultFormats |
|||
implicit val formats = DefaultFormats |
|||
case class Task(pageid: Int, title: String) |
|||
case class Category(categorymembers: List[Task]) |
|||
case class Query(query: Category) |
|||
List("Programming Tasks", "Scala") |
|||
.map { title => |
|||
sttp |
|||
.get(uri"http://www.rosettacode.org/mw/api.php?action=query&list=categorymembers&cmtitle=Category:${title}&cmlimit=1000&format=json") |
|||
.header("User-Agent", mozillaUserAgent) |
|||
.response(asJson[Query]) |
|||
.send() |
|||
.body |
|||
} |
|||
.map { |
|||
case Right(r) => r.query.categorymembers.toSet |
|||
case Left(s) => Set.empty[Task] |
|||
} |
|||
.foldRight(Set.empty[Task])((acc: Set[Task], ele: Set[Task]) => acc -- ele) |
|||
</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |