Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • About Bonfire
Simon Brooke
Simon Brooke
@simon_brooke@mastodon.scot  路  activity timestamp 4 days ago

In #Clojure, if you query a set for a member, and that member is present, that member is returned:

user=> (#{:a 馃槣 :c} :a)
:a

The traditional #Lisp function ASSOC has the signature

(ASSOC store key) => value

where store is assumed to be a list of (key . value) dotted pairs.

In the experimental Lisp I'm working on, I want you to be able to put maps onto assoc lists as well as (key . value) pairs, which raises the questions...

/Continued

  • Copy link
  • Flag this post
  • Block
Simon Brooke
Simon Brooke
@simon_brooke@mastodon.scot replied  路  activity timestamp 4 days ago

1. What is the value of an arbitrary atom/string/keyword/number as a top level form in an assoc list; and
2. What is a set?

It occurs to me that a set could be implemented either as a hashmap where all values were their own keys, or as a hashmap there every value was T.

Which then gets us back to the assoc list.

/Continued

  • Copy link
  • Flag this comment
  • Block
Simon Brooke
Simon Brooke
@simon_brooke@mastodon.scot replied  路  activity timestamp 4 days ago

Suppose we have an assoc list, called 'store', with the structure:

((:one . 1) {:two 2 :three 3 :four 4} :five (:six . 6))

Then clearly,

(assoc store :1) => 1
(assoc store :three) => 3

Does it make sense to you that (assoc store :five) should return :five, which would be consistent with what #Clojure does with sets, or shout it instead return T?

I'm inclined to the latter, but I'm open to persuasion.

  • Copy link
  • Flag this comment
  • Block

BT Free Social

BT Free is a non-profit organization founded by @ozoned@btfree.social . It's goal is for digital privacy rights, advocacy and consulting. This goal will be attained by hosting open platforms to allow others to seamlessly join the Fediverse on moderated instances or by helping others join the Fediverse.

BT Free Social: About 路 Code of conduct 路 Privacy 路
Bonfire social 路 1.0.1 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Code of Conduct