Arc Forumnew | comments | leaders | submit | babo's commentslogin
2 points by babo 6278 days ago | link | parent | on: Arc runs in DrScheme

It's OK even with the latest version of DrScheme with pg's original source, while fails from command line mzscheme.

-----

2 points by babo 6283 days ago | link | parent | on: The proposed : syntax

Is your code publicly available?

-----

2 points by babo 6285 days ago | link | parent | on: Improve your arc REPL

  #!/bin/sh
  rlwrap -C arc mzscheme -m -e '(load/cd "~/src/arc0/as.scm")'

-----

4 points by babo 6285 days ago | link | parent | on: Rubylike slice for strings and lists

This patch against arc.arc gives you similar functionality:

  (def subseq (seq start (o end (len seq)))
  -  (if (isa seq 'string)
  -      (let s2 (newstring (- end start))
  -        (for i 0 (- end start 1)
  -          (= (s2 i) (seq (+ start i))))
  -        s2)
  -      (firstn (- end start) (nthcdr start seq))))
  +  (with (
  +    start (if (< start 0) (+ (len seq) start) start)
  +    end (if (< end 0) (+ (len seq) end) end)) 
  +    (if (isa seq 'string)
  +        (let s2 (newstring (- end start))
  +          (for i 0 (- end start 1)
  +            (= (s2 i) (seq (+ start i))))
  +          s2)
  +        (firstn (- end start) (nthcdr start seq)))))

  (subseq "hello" 0 -1) => "hell"
  (subseq "hello world" -5) => "world"
  (subseq "hello world" -4 -2" => "or"
Interpreting the second parameter as an offset if it's greater than 0 probably much more useful, I'll try it out later today.

-----