Comments (4)
Probably not as a core data structure, although it would be possible to add one as an abstract type. Abstract types cannot emulate all of the features of built in types right now, such as length, hash, equality, call, and print methods, but I would consider adding some of these features to the abstract type interface.
All that said, I think there is benefit to using a few core data structures - enough for many use cases, but few enough that making generic functions is easy.
You could of course also do something like:
(defn make-set
[& els]
(let [tab @{}]
(each el els (put tab el true))
(table/to-struct tab)))
(make-set :a :b :c)
# -> {:c true :a true :b true}
from janet.
oops, I don't know about abstract types
, what do we already have for now?
from janet.
Abstract types are native C types, you would have to write your own in C. The current abstract types in the core are files and typed arrays, and there are some others in external packages.
I would recommend using tables for sets, though.
from janet.
The package index references janet-set, an implementation of set types in Janet.
Janet-set uses janet-abstract (https://github/mikebeller/janet-abstract.git) in order to create a new abstract type directly in Janet. This allows us to "hook" into get/put/tostring/next so that our sets will support length calls, normal Janet iteration, and print out in a sensible way.
from janet.
Related Issues (20)
- Error stating 3 is not an integer? HOT 3
- if-let macro behavior changed? HOT 3
- After a stream is created ev/sleep takes 100% CPU. HOT 4
- Support a cosmopolitan target HOT 8
- error: cannot marshal fiber with c stackframe HOT 2
- (default) not working HOT 6
- Cannot load native module with MinGW (GC error) HOT 9
- Splicing a tuple into an indexed literal causes subsequent form to compile incorrectly HOT 4
- `os/rename` behaves differently on Linux vs Windows HOT 2
- (doc next) doesn't mention fiber HOT 1
- Potential arity check bug in peg.c HOT 4
- Bugs when cancelling a waiting fiber HOT 5
- Advent of Code, day 7 - non-deterministic output
- macex raises on () HOT 8
- segfault can result if `net/server`'s handler has incorrect arity
- `ev/deadline` and `ev/with-deadline` should be documented better. HOT 1
- (some) returns first truthy predicate result, not first truthy item HOT 6
- let* please, possibly even letrec, letrec* HOT 4
- janet fails to run with 'error while loading shared libraries' HOT 7
- Improve sandboxing to allow more granular permissions HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from janet.