Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Francisco Felipe Suero
@thecog19
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.
Shivansh Suhane
@shivansh_suhane_twitter
Hey I'm new to sibilant and playing around. I'm stuck with a piece of code
how would we check if a element exists in dictionary?
Jacob Rothstein
@jbr
Shivansh Suhane
@shivansh_suhane_twitter
Cool! I wasn't sure if anyone is here but that helps!
Jacob Rothstein
@jbr
Thanks for learning sibilant!
Shivansh Suhane
@shivansh_suhane_twitter
Thanks for the help!

Actually, if you have a moment, I'd appreciate one more thing. I'm trying to do the following:

if (cur in d){
d[cur]+=1
}
else{
d[cur]=0
}
}

But in sibilant. I'm stuck at:

(each str inputStr
(console.log str)
if (has-key? d str) (d[str]+=1) (d[str]=0)
)

@jbr
Jacob Rothstein
@jbr
(each str input-str 
  (console.log str)
  (if (has-key? d str)
    (incr (get d str))
    (set d str 0)))
i think you want something like that maybe?
or equivalently,
(each str input-str 
  (console.log str)
  (set d str (if (has-key? d str)
    (+ 1 (get d str))
    0)))
Shivansh Suhane
@shivansh_suhane_twitter
Thanks! That makes complete sense
Shivansh Suhane
@shivansh_suhane_twitter
@jbr Do we have sort or reverse in Sibilant? If not, I could try to contribute sorting! Documentation doesn't mention sort anywhere.
(var x [ 4 1 5 2 3])
(.sort x)
(console.log x) ;; ⇒ [ 1 2 3 4 5 ]
Shivansh Suhane
@shivansh_suhane_twitter
That's super cool! I was getting weird errors trying it as the syntax was wrong 😅
Jacob Rothstein
@jbr
and for reverse: (.reverse x). to chain reversing and console.logging, check this out: (|> [ 1 2 3 4] .reverse console.log) which is the same as console.log([ 1, 2, 3, 4 ].reverse())
you can also just do (x.sort) or (x.reverse) instead of (.sort x) or (.reverse x), they both work
Shivansh Suhane
@shivansh_suhane_twitter

Ah interesting, I was doing something like:

(var result Object.entries(d))
(.sort result)
(.reverse result)
(console.log result)

but the chain linking is super cool

Could we sort by the second value in a 2-d array?
Jacob Rothstein
@jbr
yeah, that would be an argument to the Array.prototype.sort function
Shivansh Suhane
@shivansh_suhane_twitter

Think I understand the JS version:

function comparator(a, b) {
if (a[1] > b[1]) return -1
if (a[1] < b[1]) return 1
return 0
}

myArray = myArray.sort(comparator)

Jacob Rothstein
@jbr
so sorting by the second element in sibilant might look like:
(var x [[0 1] [ 3 5] [ 0 0 ]])
(.sort x (#([a b] [c d])
  (if (< b d) -1
      (= b d) 0
      1)))
(console.log x)
(if i got the logic right)
Shivansh Suhane
@shivansh_suhane_twitter
That worked like a charm. Thanks!
Jacob Rothstein
@jbr
:tada:
Shivansh Suhane
@shivansh_suhane_twitter
🥳🥳
motivate
@motivate:matrix.org
[m]
I need your help
regarding sorting this
I want my count to be printed in descending order
but I am not able to do it in sibilant
please help
I am using this
code
from above reference
Jacob Rothstein
@jbr
could you reformat that as one code block? it's hard to tell what you're doing
I don't see anything about sorting in that code block