exercism / v3

The work-in-progress project for developing v3 tracks
https://v3.exercism.io
Other
170 stars 162 forks source link

[Clojure] Implement new Concept Exercise: `vectors` #724

Closed bobbicodes closed 3 years ago

bobbicodes commented 4 years ago

This issue describes how to implement the vectors concept exercise for the Clojure track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Goal

The goal of this exercise is to teach the student how vectors are used in Clojure. This is also the first major point of departure from Lisps which use lists primarily, providing a clean distinction between code (i.e. lists, which always represent a function call and are executed), and data, which is not. Vectors have tremendous utility and are extremely common, and used to designate local bindings, arglists and destructuring syntax.

Things to teach

Things not to teach

No knowledge of functions is assumed at this point, but it should probably be mentioned that vectors are functions which retrieve their elements by their index.

Concepts

Prerequisites

This is a root-level concept and not dependent upon any others.

Resources to refer to

Hints

After

Representer

No special requirements are needed for this exercise.

Analyzer

No special requirements are needed for this exercise.

Implementing

To implement a concept exercise, the following files must be created:

languages
└── clojure
    └── exercises
        └── concept
            └── <SLUG>
                ├── .docs
                |   ├── instructions.md
                |   ├── introduction.md
                |   ├── hints.md
                |   └── after.md (optional)
                ├── .meta
                |   |── design.md
                |   └── Example.clj
                ├── <NAME>.clj
                └── <NAME>_test.clj

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

bemself commented 4 years ago

@porkostomus very nicely explained, I learned a lot also! I have a quick question, apart from vectors is a function in Clojure, I feel like it's quite similar to Java List or Array, am I right?

The vector concepts unlocks quite some concepts below, I'm kind of lost how we handle this in the implementation of this concept vector, do we explain them individually or simply link to some references?

bobbicodes commented 4 years ago

I think the main difference with arrays is the way they are implemented. I think arrays are usually contiguous blocks in memory, but Clojure's vectors are actually the same "hash-array map tries" as in Clojure maps.

bobbicodes commented 3 years ago

Finished, see #1835