Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Jacob Rothstein
@jbr
Or [1 2 3 …a], etc
And there’s always Array.prototype.push, pop, etc
(var a [ 1 2 3 ]) (.push a 4) (.unshift a 0)
Jason Fu
@jasonfu9966
yeah I was trying (.unshift a ...b) and it wasn't keeping the spread, where a and b are both arrays
Jacob Rothstein
@jbr
i don’t think js’s unshift accepts more than one item at a time
you could reassign to a, like (assign a […a …b])
Jason Fu
@jasonfu9966
yeah, that looks like it'll work. thanks
your interactive in-browser compiler is magic, by the way. saving me a lot of time and effort
Jacob Rothstein
@jbr
Yay! 😊
are you using the one on sibilant.org or docs.sibilant.org?
Jason Fu
@jasonfu9966
docs
is there one on sibilant.org? if so, there's no easy-to-find button for it
Jacob Rothstein
@jbr
i think the docs one is easier, but all of the examples on sibilant.org are editable
Jason Fu
@jasonfu9966
oh you mean the examples yeah
Jacob Rothstein
@jbr
yeah. i probably should add a compiler popover like docs has to the main site. or a route that’s just that
Jason Fu
@jasonfu9966
that'd be nice
or maybe a separate page entirely, so we aren't so restricted by space
Jacob Rothstein
@jbr
Yeah. it’d be cool to add some of the features on play.rust-lang.org, like the ability to type out some code and share a quick link without saving anything
(it encodes the whole thing into the url)
Jason Fu
@jasonfu9966
that'd be neat
by the way, in case you've haven't heard why there have been becoming interested in Sibilant in the last few months... it's because a company has included it in their interview loop
hello, future interviewees
Jacob Rothstein
@jbr
whoa really? that’s awesome
are you affiliated with the company?
Jason Fu
@jasonfu9966
I'll PM you details so nobody can see the answers
Jacob Rothstein
@jbr
:thumbsup:
George Offley 🏳️‍🌈
@georgeoffley_twitter
Hello everyone! I'm just starting to learn sibilant and I am trying to figure out how to call key vs values for hash objects.
(var tasks (hash "task 1" "task dependent 1" "task2" "task dependant2"))
That's my code for the hash object and I am trying to find a way to call the values (or the task dependents). I can see that I can loop through the keys but the docs don't seem clear on how to reference the corresponding values. Or maybe I'm just not clear on it.
If someone could help that would be awesome.
George Offley 🏳️‍🌈
@georgeoffley_twitter
Never mind, just discovered get for grabbing values for specific keys. I'm dumb, just read the docs lol
Still I gotta say, I've never even looked at lispy type languages and this is kinda nuts lol
Jacob Rothstein
@jbr
:wave: hi @georgeoffley_twitter you can also build a hash using json syntax, like (var tasks {“task 1”: “task dependent 1”, “task 2”: “task dependant2”})
and you can use any of the functions for interacting with objects that are in js, like Object.keys and Object.values
and to go from a key to a value, as you found, there's (get tasks “task 1”) or similar
which compiles to tasks[“task 1”]. if the keys are like ”task1" instead of ”task 1”, you can access them with dot notation (tasks.task1), just like in javascript
George Offley 🏳️‍🌈
@georgeoffley_twitter
Thanks!
That's actually good to know, I'm trying to figure out why I'm getting errors for what I built and I think rewriting some of it would help!
George Offley 🏳️‍🌈
@georgeoffley_twitter
Actually, if anyone could take a look and point me in the direction of where I'm going wrong I'd be grateful
(def ordered-tasks (task-list current-task)
    (var tasks-in-order [])

    (while (> (length tasks-in-order) 3)
        (var dependent-task (get task-list current-task))
        (if
            (= "" (get task-list dependent-task)) 
                (append dependent-task tasks-in-order)
            (append current-task tasks-in-order)
        )
    )

        (console.log tasks-in-order)
)


(ordered-tasks(tasks "make a sandwich"))
When I try to run that I get TypeError: orderedTasks(...) is not a function
The logic isn't exactly where I need it to be but I can't get this to run
The tasks argument is a hash type object as pointed out above
George Offley 🏳️‍🌈
@georgeoffley_twitter
Actually. I think I got it to run. Only issue now is the confusing way while loops and the if conditionals are set up
Ricardo Figueroa Riestra
@rfigueror1
Hi there, how can I concatenate arrays together? I am trying [1 2 4].concat( [3 5 8]).
Jacob Rothstein
@jbr
Scroll up for a discussion of that. [...[1 2 4] ...[3 5 8]] would work
(Or more commonly, with variables instead of sub array literals)
Ricardo Figueroa Riestra
@rfigueror1
thanks!
Jacob Rothstein
@jbr
Or (.concat [1 2 4] [3 5 8])
Ricardo Figueroa Riestra
@rfigueror1
Hi, are multi-line comments supported?
Jacob Rothstein
@jbr
Nope, just one line with ;;