Arc Forumnew | comments | leaders | submit | jsgrahamus's commentslogin
2 points by jsgrahamus 4965 days ago | link | parent | on: Apologies for the frequent downtime

I haven't experienced the downtime. However, I would like to use it on my Android, but the Enter key does not seem to end the input line. Any ideas on how to handle that?

Thanks, Steve

-----

1 point by evanrmurphy 4965 days ago | link

Hi Steve, have you had a chance to try this on your Android since yesterday? I think the update I made to fix copy-paste may have also fixed this.

The reason I say this is that I just tried it on my Android - a Samsung/Google Nexus S - and it worked (the Enter key did successfully end the input line). But it may also be due to us having different phones, so when you get a chance to try it out again, please let me know.

Also, thanks for your patience and for reminding me about this issue. I remember you first raising it a long time ago.

-----

1 point by jsgrahamus 4965 days ago | link

I have a T-Mobile G-1 and it does not terminate the line. Perhaps because I have version 1.6.

You're welcome of course.

-----

1 point by evanrmurphy 4964 days ago | link

Ok, thanks. I've created an issue for this in the Feedback forum, which is my running todo list for try arc: http://tryarc.uservoice.com/forums/80605-general/suggestions...

-----

1 point by jsgrahamus 4965 days ago | link | parent | on: Apologies for the frequent downtime

  arc> (def 1st-diff (str1 str2 i)
    (if (or (is str1 "") (is str2 ""))
      0
      (or (> i (- (len str1) 1)) (> i (- (len str2) 1)))
      i
      (no (is (str1 i) (str2 i)))
      i
      (1st-diff str1 str2 (+ i 1))))
  #<procedure: 1st-diff>
  arc> (1st-diff "" "" 0)
  0
  arc> (1st-diff "" "" 0)
  0
  arc> (= astring "abcde")
  "abcde"
  arc> (= bstring "abced")
  "abced"
  arc> (1st-diff "" "" 0)
  0
  arc> (1st-diff astring "" 0)
  0
  arc> (1st-diff "" astring 0)
  0
  arc> (1st-diff astring bstring 0)
  3
  arc> (1st-diff bstring astring 0)
  3
  arc> (1st-diff astring "abcdef" 0)
  5
  arc> (1st-diff "abcdef" astring 0)
  5
  arc>

-----

1 point by jsgrahamus 4965 days ago | link

It's interesting to compare this to the solution in my workday language. One of the reasons that M is shorter is because its functions are more tolerant. For arc, I had to make sure that the index to the string was not too large. In M, it simply returns an empty string if you attempt to access a string position beyond the length. And I used iteration with M. Perhaps the arc solution would have been shorter had I done the same there.

Interesting exercise for this newbie.

-----

2 points by akkartik 4965 days ago | link

Yeah you can index past the end in my arc variant (http://github.com/akkartik/wart). But it currently returns nil. What should it be?

I'd love to see the M version expanded into english.

-----

2 points by jsgrahamus 4965 days ago | link

Great.

I'm used to seeing it as the empty string

Here is the expanded M version (! = LF):

  IF X=Y WRITE !,0 ; No difference
  ELSE  FOR I=1:1 IF $EXTRACT(X,I)'=$EXTRACT(Y,I) WRITE !,I QUIT

-----

1 point by akkartik 4964 days ago | link

I still don't know enough MUMPS to follow it :)

Are you concatenating strings? Is that where returning "" is useful? In wart concatenating strings is tolerant of non-strings, so I think returning nil should be ok.

-----

2 points by jsgrahamus 4963 days ago | link

If the string X = the string Y, print 0 (to indicate there are no differences / MUMPS uses 1-based indexing of strings)

Otherwise, go through each character of the strings and at the point where they differ, print that index and quit looping.

MUMPS does not error out on attempting to extract a character beyond the string's length. So in that event, 1 string's extract will return the empty string, which will differ from the other string's extract and will cause you to print the index and quit. Not generating such an error, of course, cuts down on the code needed.

-----

2 points by zck 4964 days ago | link

So if we enter the for loop, we know there is a difference between the two sequences.

So we just need to find an index position i where (isnt seq1.i seq2.i) is true. If indexing off the end of a string causes an error, we need to put in code to prevent that. If indexing off the end of a string returns anything that can't be an element of the string, we can compare each index i until we find a difference, knowing that we'll eventually find one.

-----

1 point by jsgrahamus 4963 days ago | link

Correct.

-----

1 point by jsgrahamus 4965 days ago | link | parent | on: Apologies for the frequent downtime

test-iso?

-----

1 point by akkartik 4965 days ago | link

https://github.com/nex3/arc/blob/ec47676f99af11b6fa8935a3cb0...

-----

1 point by jsgrahamus 4965 days ago | link | parent | on: Using arc on production system

I'm wondering about something which might have high document storage requirements. I guess it would have to be web-based (don't know how exactly one would integrate arc with another GUI environment).

I know I've seen comments here about integrating it with a db. Anyone remember the article # or URL?

Thanks, Steve

-----

2 points by thaddeus 4965 days ago | link

Here are some options for you:

Option 1. Use Fleetdb.

http://fleetdb.org/. Here's some rudimentary code to make this work with anarki: http://blackstag.com/fleetdb-client.arc

Option 2. Use any database that supports an HTTP interface.

You can use the anarki http library here: https://github.com/nex3/arc/blob/master/lib/http.arc along with something like Riak or Couchdb, etc.

Option 3. MySql over HTTP:

http://code.nytimes.com/projects/dbslayer

Option 4. Get the FFI working to access MySql and other more traditional database systems.

Some people had been working on the FFI interface, but so far I've yet to see anything that works. You can read my noob entry about this here: http://arclanguage.com/item?id=10839 and there were recent attempts by others as well.

-----

1 point by jsgrahamus 4965 days ago | link

Some good ideas. Thanks, Thaddeus. Steve

-----

2 points by jsgrahamus 4966 days ago | link | parent | on: Apologies for the frequent downtime

Can you employ Racket's libraries for what you need?

-----

1 point by zck 4965 days ago | link

Some of it. What I've been working on lately is trying to get the Twitter API to work with Arc. I haven't found any Racket libraries for Twitter or even for OAuth. I would be very excited to find one, though -- this project has been [stuck](http://arclanguage.com/item?id=16040) for [way](http://arclanguage.com/item?id=15207) too [long](http://arclanguage.com/item?id=14817).

-----

1 point by evanrmurphy 4966 days ago | link

That worked for me with Try Arc. It's really not a large program, the portion that I wrote. On the backend, all the heavy lifting is done by Racket's sandbox library and srv.arc. On the front-end, it's Chris Done's jQuery console (and to some extent now, WordPress).

-----

3 points by jsgrahamus 4966 days ago | link | parent | on: Apologies for the frequent downtime

In my work language:

  I X=Y W !,0 ; No difference
  E  F I=1:1 I $E(X,I)'=$E(Y,I) W !,I Q
A challenge for me is arc/lisp/scheme's verboseness.

-----

1 point by akkartik 4966 days ago | link

What is that, J?

-----

1 point by rocketnia 4966 days ago | link

I think you may already have an inkling somewhere in the back of your mind.... http://arclanguage.org/item?id=15341

-----

1 point by akkartik 4966 days ago | link

Lol.

-----

1 point by jsgrahamus 4965 days ago | link

MUMPS / M / Caché - Used it for most of 30 years. In the U.S. mostly used on medical information systems, however it is also used in banks, credit unions, Ameritrade, etc.

-----

1 point by jsgrahamus 4967 days ago | link | parent | on: Reading from a file

So, I was thinking of using arc for an easy task. I have a file with a line of text, a blank line, a line of text, etc. I wanted to rewrite it without the blank lines.

Looking into the link below I found code for reading a file: arc> dev "c:\\Users\\Steve\\Desktop\\mbrm.txt" arc> (w/instring ins dev (whiler l (readline ins) nil (prn "{" l "}"))) {c:\Users\Steve\Desktop\mbrm.txt} nil arc>

However I don't see any lines read. Any ideas?

Thanks, Steve

-----

1 point by jsgrahamus 4967 days ago | link

Sorry about the formatting. I thought the key was to put 2 spaces at the front of the line.

arc> dev

"c:\\Users\\Steve\\Desktop\\mbrm.txt"

arc> (w/instring ins dev

       (whiler l (readline ins) nil

                 (prn "{" l "}")))
{c:\Users\Steve\Desktop\mbrm.txt}

nil

arc>

C:\Users\Steve\Desktop>dir mbrm*

Volume in drive C is TI105757W0A

Volume Serial Number is 48C4-C0F7

Directory of C:\Users\Steve\Desktop

04/26/2012 11:15 AM 254,785 mbrm.txt

04/26/2012 11:35 AM 242,988 mbrm2.txt

               2 File(s)        497,773 bytes

               0 Dir(s)  146,673,606,656 bytes free

C:\Users\Steve\Desktop>

-----

2 points by zck 4967 days ago | link

One note:

  (whiler line (readline file) nil ...)
can be replaced by:

  (whilet line (readline file) ...)
Read it as "while-let"; the spelling confused me for a while.

-----

1 point by jsgrahamus 4966 days ago | link

That's shorter. What are any other differences? I copied the first one from the docs and am not sure what the nil was for.

Thanks.

-----

3 points by zck 4966 days ago | link

They're very similar. Check out http://files.arcfn.com/doc/iteration.html#whilet for some better documentation, but it boils down to this:

  (whilet var test ...)
loops until (no (test)) is true -- until (test) returns 'nil. Each loop through, var is bound to the value of (test). On the other hand,

  (whiler var expr endval ...)
loops until (is (expr) endval) is true. Similarly, each loop through, var is bound to the value of (expr).

So every time you have a call to

  (whiler value (function) nil ...)
You can replace that with

  (whilet value (function) ...
An example of when you would want to use whiler is:

  (whiler input (readline) "quit" (do-stuff-with-input-from-user input))

-----

1 point by jsgrahamus 4966 days ago | link

Good explanation. Thanks.

-----

1 point by jsgrahamus 4967 days ago | link

I really should learn to read and understand before

writing....

arc> (w/infile inf dev

        (whiler l (read inf) nil (prn "{" l "}")))
Here is a sample of the output:

{Arcanobacterium}

{has}

{been}

{strongly}

{associated}

{with}

{pharyngitis}

{(fn (_) (often with the presence of scarlatiniform rash))}

Error: "c:/Users/Steve/Desktop/mbrm-new.txt::13563: read:

illegal use of \".\""

It is odd that it errored and that it is only picking up a

word at a time instead of a line.

-----

1 point by jsgrahamus 4967 days ago | link

Reading comes to the rescue again:

arc> dev

"c:/users/steve/desktop/mbrm-new.txt"

arc> (w/infile inf dev

        (whiler l (readline inf) nil (prn l)))
...

VZ Varicella zoster virus Varicella zoster virus

VZV Varicella Varicella Zoster isolated

W White White

WADA Wangiella dermatitidis Wangiella dermatitidis

WBCS WBCs seen WBCs seen

WDER Wangiella dermatitidis Wangiella dermatitidis W. dermatitidis

WESP Weeksella species Weeksella species Weeksella sp.

WEVI Weeksella virosa Weeksella virosa W. virosa

WEZO Weeksella zoohelcum Weeksella zoohelcum W. zoohelcum

WHITE White White

WNF Normal flora also recovered Normal flora also recovered

WOO The specimen was collected The specimen was collected with a wooden shafted swab. Wood components may inhibit virus isolation. Interpret these negative results with caution.

...

nil ...

-----

1 point by waterhouse 4967 days ago | link

The "read" procedure will read only a single Arc expression at a time. If you want to read a line, there is a "readline" procedure.

Also, it is correct that you make code look like code by putting two spaces before each line of code.

  After "code." in the above paragraph, there is a newline, then
  another newline, then two spaces, then "After [...] newline, then",
  then another newline, then two spaces, then "another", and so on.

-----

1 point by jsgrahamus 4967 days ago | link

See reply.

-----

1 point by jsgrahamus 4967 days ago | link

Thanks for the editing tips.

  arc> dev
  "c:/users/steve/desktop/mbrm-new.txt"
  arc> (w/infile inf dev
          (whiler l (readline inf)
             nil
             (if (no (is l "\r"))
                 (prn l))))

  ...
   
  YT      Yeast   Yeast   Yeast
  YTNC    Yeast not Cryptococcus  Yeast not Cryptococcus  Yst not Cryptococcus
  YTSP    Yeast species   Yeast species   Yeast sp.nentgd  Group D, streptococcus  Group D, streptococcus  Group D
  oi      Over-inoculated Over-inoculated Over-inoculated
  orgnv   Organism non-viable     Organism non-viable     Organism non-viable
  oxnego  Oxidase Negative Other  Oxidase Negative Other  Oxidase Negative
  p27853  Pseudomonas aeruginosa ATCC 27853       Pseudomonas aeruginosa ATCC 27853       P. aerug ATCC27853
  pacica  Presumptive Acinetobacter lwoffi        Presumptive Acinetobacter lwoffi        Presumptive A.lwoffi
  stlu    Staphylococcus lugdunensis      Staphylococcus lugdunensis (coagulase negative species) S. lugdunensis
  nil
  arc>

-----

1 point by jsgrahamus 4967 days ago | link | parent | on: Reading from a file

And, I thought there was a keyword index on the wiki. URL?

Thanks again.

-----

1 point by akkartik 4967 days ago | link

Perhaps you're thinking of http://files.arcfn.com/doc?

-----

1 point by jsgrahamus 4967 days ago | link

Yes. Thanks.

-----

1 point by jsgrahamus 4996 days ago | link | parent | on: Shen in 1kLoC of Clojure

What do you see as the practical benefits of Shen?

-----

1 point by akkartik 4996 days ago | link

Still too early to say since this is the first implementation for linux or mac.

-----

4 points by jsgrahamus 5004 days ago | link | parent | on: The origins of BitC

They had an interesting reason to use/discard Lisp:

"The real reason we stuck with the LISP-ish syntax is that we didn't want to be fiddling with the parser while designing the language, and (to a lesser degree) because we didn't want to encourage programmers until we thought the language was ready. We are now preparing a more sensible surface syntax, whereupon we will receive rotten egg and tomato complaints from the LISP community. You can't please everyone. Using the LISP syntax for so long let us focus on what was really important."

-----

More