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
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 ;;
Ricardo Figueroa Riestra
@rfigueror1
thanks
Francisco Felipe Suero
@thecog19
Just getting started with sibilant, i'm trying to do something relatively simple, where i iterate over an array of objects and perform some transformations. My issue is I can't quite figure out how to do two things in one pass. Example to follow:
(each item item-list (
        (
            set item "listed" false
        )
        (item)
        )
    )

works like a charm

 (each item item-list (
        (
            set item "listed" false
            set dict (get item "name") item
        )
        (item)
        )
    )

(and various variations) all seem to not work

I'll keep poking at the documentation, I'm sure its just my unfamiliarity with lisp, but I'd appreciate any help :)
Jacob Rothstein
@jbr
The parens are an important part of the syntax
Each function call needs its own parens
Francisco Felipe Suero
@thecog19
Yeah, I tried something like
 (each item item-list (
        (
            (set item "listed" false)
            (set dict (get item "name") item)
        )
        (item)
        )
    )
but trying to execute more than one instruction has it blow up with
SyntaxError: Unexpected token ;
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at runInSandbox$ (/home/felipe/.nvm/versions/node/v6.10.2/lib/node_modules/sibilant/maps/src/cli.sibilant:16:7)
    at /home/felipe/.nvm/versions/node/v6.10.2/lib/node_modules/sibilant/maps/src/cli.sibilant:116:9
    at /home/felipe/.nvm/versions/node/v6.10.2/lib/node_modules/sibilant/maps/src/cli.sibilant:105:7
    at Array.forEach (native)
    at Object.<anonymous> (/home/felipe/.nvm/versions/node/v6.10.2/lib/node_modules/sibilant/maps/src/macros/lists.sibilant:101:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
Jacob Rothstein
@jbr
You have extra parens
And you donโ€™t need parens around item on the third from last line
Check the parens in the each example
Francisco Felipe Suero
@thecog19
That helped, the extra parens were the ones after item-list i appreciate the help :)
Jacob Rothstein
@jbr
Happy to help, thanks for learning sibilant!
swazonic
@sclaybon
Finally found people interested in sibilant. Is this the only forum/chat room for sibilant?
Jacob Rothstein
@jbr
Yep! As far as I know, would be elated to learn that there was another one though
swazonic
@sclaybon
Ok cool. Good to know
Jordan Rickman
@JordanRickman
Can anyone help me with this error? Happens whether I run globally (npm install -g sibilant, then sibilant) or locally from the project directory (npm install sibilant, then npx sibilant).
npx sibilant
Setting up environment with C:\Users\jrickman\env.bat
Error: ENOENT: no such file or directory, open 'undefined/.sibilant.history'
    at Object.openSync (fs.js:462:3)
    at Object.<anonymous> (C:\Main\Tresor\Dev\stitch-sibilant-challenge\node_modules\sibilant\maps\src\repl.sibilant:26:12)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.cli$repl$ [as repl] (C:\Main\Tresor\Dev\stitch-sibilant-challenge\node_modules\sibilant\maps\src\cli.sibilant:37:7)
    at Object.<anonymous> (C:\Main\Tresor\Dev\stitch-sibilant-challenge\node_modules\sibilant\maps\src\cli.sibilant:78:8)
Jordan Rickman
@JordanRickman
Okay, found the fix and opened a Github issue. Problem is that Node's process.env.HOME is not set by default on Windows.