Giter Club home page Giter Club logo

Comments (12)

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Should probably update debug to display maps correctly.

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

chunk(): fail (makes no sense)
count-values(): OK (makes no sense and looks ugly)
debug(): OK
first(): OK
insert-nth(): fail
is-symmetrical(): makes no sense
last(): OK
last-index(): fail (returns null)
loop(): OK
prepend(): OK (looks weird)
purge(): makes no sense
random-value(): fail
remove(): fail
remove-duplicates(): can't be duplicate keys in maps
remove-nth(): OK
replace(): fail
replace-nth(): fail
reverse(): OK
slice(): OK
sort(): OK
sum(): returns 0
to-string(): OK

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Added 3 functions: map-sort-keys(), map-sort-values() and map-find-keys().

from sassylists.

Snugug avatar Snugug commented on May 30, 2024

@hugogiraudel Map related functions should probably be in https://github.com/Team-Sass/Sassy-Maps instead of Lists

Additionally, debugging maps works as of RC2

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Good idea, problem is they rely on the sort() function from SassyLists. Not sure you can do anything with those 3 functions without the sort one.

from sassylists.

Snugug avatar Snugug commented on May 30, 2024

As much as I kinda hate to say it, duplicate the sort function?

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

I don't think this is a good idea. I'd rather have a clean map sort function for Sassy-Maps. Both map-sort-keys() and map-sort-values() are based on the sort() function that was initially meant to order lists, not maps.

Working out a fresh from start map function meant for maps and maps only is probably a better idea. What do you think?

from sassylists.

Snugug avatar Snugug commented on May 30, 2024

That works too. I figured your sort function had been optimized for maps, but if it hasn't, yah, working out a fresh one works

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Basically here is what I do to sort a map based on its keys (map-sort-keys):

  1. I create a list out of the keys
  2. I order the list
  3. I find back the value from the initial map for each key
  4. I make a map out of it and return it

To sort a map based of its values (map-sort-values), it's slightly more tricky since there can be multiple keys sharing the same values, so I need the helper function map-find-keys:

  1. I create a list out of the values
  2. I order the list
  3. I find back the keys matching each value and exclude them in a temporary list
  4. I make a map out of it and return it

Kind of a big process but since the sort() function is probably the most complicated one from SassyLists, I didn't want to duplicate it just to deal with maps.

On topic, I'm not sure how to do it with less code if we want to deal with maps only for Sassy-Maps, but I'll have a look at it if you want.

from sassylists.

Snugug avatar Snugug commented on May 30, 2024

I'm not sure, we should move this discussion to Sassy Maps

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Let's go. I let you open an issue. )

from sassylists.

KittyGiraudel avatar KittyGiraudel commented on May 30, 2024

Won't fix.

from sassylists.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.