Book Image

Clojure Data Structures and Algorithms Cookbook

By : Rafik Naccache
Book Image

Clojure Data Structures and Algorithms Cookbook

By: Rafik Naccache

Overview of this book

Table of Contents (14 chapters)
Clojure Data Structures and Algorithms Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Querying a social website's data


Assume that you run a social networking website. On such a website, your users might be have "friendly" relations with other users. Besides, you have access to some data related to their behavior, such as information about what items they've bought from your website.

The goal of this recipe is to capture these relationships and behavior-related data, so that we are able to derive interesting facts out of them. As it turns out, it is possible in core.logic to specify facts that are relations between data and to query these relations in goals.

In the following section, we will answer the questions: who are a given user's friends? Who is reachable from a user's network? What did someone's friend buy? You'll even see that this last question can be turned the other way around. You'll be able to answer which users have friends that have bought a particular item, using the same previously developed routine!

How to do it…

  1. For starters, here is the ns declaration that...