Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jun 18, 2012 15:02:35 GMT 1
I've found this site by coincidence. Here is a short description: What do you think about adding BaCon to that site? Several BASIC dialects are already there. Link - rosettacode.org/wiki/Rosetta_Code.
|
|
|
Post by bigbass on Jun 18, 2012 16:33:31 GMT 1
Hey Tomaaz we have some code converted from rosetta to BaCon already basic-converter.proboards.com/index.cgi?board=bugs&action=display&thread=187my last post there shortens the C example a lot and fixes a compile error in the rosetta C code and then I added user input so this is a USEC example Then GatorDog rewrote the fixed C code to pure BaCon and made a function ;D it was not submitted though yes I think we need a BaCon example for rosetta we have a first going already Joe
|
|
|
Post by vovchik on Jun 18, 2012 18:48:30 GMT 1
Dear Tomaaz and Joe,
I think it is a good idea to post at Rosetta - and will at least make others aware of BaCon. I found in my string lib this implementation of STRING:
FUNCTION STRING$(NUMBER Quantity, STRING MyChar$) ' **************************************************************************** ' * Quantity = 4 and Mychar$ = "!!" yields output string of "!!!!!!!!" ' * NB: Somewhat like QB STRING$ function ' **************************************************************************** LOCAL NewString$ LOCAL I NewString$ = "" FOR I = 1 TO Quantity NewString$ = CONCAT$(NewString$, MyChar$) NEXT I RETURN NewString$ END FUNCTION
' -------- ' Example: ' PRINT "STRING$(length, string)" ' y$ = STRING$(5, "!!!!") ' PRINT "y = STRING$(", "5, ", CHR$(34), "!!!!", CHR$(34), ")" ' PRINT "STRING$(5,",CHR$(34), "!!!!", CHR$(34), ")", " returned: ", y$ ' PRINT ' --------
With kind regards, vovchik
|
|
|
Post by Pjot on Jun 19, 2012 18:01:11 GMT 1
Thanks Tomaaz,
Interesting site! Though I am not sure if BaCon really can contribute something there in terms of original solutions? Because it seems there are a lot of BASIC examples on the site already, most of which will work in BaCon almost without modification...
Best regards Peter
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jun 21, 2012 14:45:50 GMT 1
Because it seems there are a lot of BASIC examples on the site already, most of which will work in BaCon almost without modification... True, but BASIC is the language that has more dialects than a total number of other languages is. And BACON is definitely one of the most BASIC-like ones. What we can do is to check if people here are interested in contributing to that site. If anyone wants to share his code, please post it here first and if we have certain number of examples, we'll think about posting it on Rosetta Code. I can contribute my fractals (these tasks are already there) and word counting program.
|
|
gcav
New Member
Posts: 34
|
Post by gcav on Dec 14, 2012 15:44:39 GMT 1
I was going to add the Hello world/webserver for BaCon, but since I have to create _yet another_ web account I balked at it.. Here is the sample: OPEN "localhost:8080" FOR SERVER AS handle RECEIVE dat$ FROM handle SEND "Hello BACON World" TO handle CLOSE SERVER handle Cant get easier than this... This is why I support Peter's "Spoken language constructs are preferred" tenet other languages examples... rosettacode.org/wiki/Hello_world/Web_server
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 14, 2012 21:12:37 GMT 1
It's a great way to review how different languages approach a common task. I see it as another way to get BaCon in front of programmers faces.
|
|
|
Post by btiffin on Feb 16, 2017 23:50:32 GMT 1
Excuse the necro posting. I've added BaCon to Rosetta. Most times edits will be fairly simple, adding a {{works with|BaCon}} tag to BASIC entries, but there are quite a few Rosetta entries where BaCon will offer unique solutions. Especially the AS SERVER, USEC and other extensions. I'll try and come up with a few highlights over the next few evenings, but this is a call out to the experts and other fans of BaCon. rosettacode.org/wiki/Reports:Tasks_not_implemented_in_BaConBaCon deserves a set of pages. It might be a "make work" project for us fans, but it will also be some good press, once people see the powers inherent in the implementation. There is quite a bit of low hanging fruit, but the real treats will be some solutions to the more complex tasks, and that is where the experts and old hands come in. Have good, make well, Brian
|
|
|
Post by Pjot on Feb 17, 2017 19:57:59 GMT 1
Thanks Brian, Looking at the list of pages, there's a lot to do Hopefully, the new extensions added in v3.5 related to delimited strings, rarely found in a BASIC (or other languages), can make an impressive contribution! Best regards Peter
|
|
|
Post by btiffin on Feb 17, 2017 23:08:12 GMT 1
Just a heads up to anyone wanting to enter a task solution, and please doIt usually goes like (after logging in to Rosetta): Click Edit on the task top if BaCon isn't in there yet, otherwise to make updates just click the Edit button beside the BaCon subheading. Keep the listing in alphabetical order, so on first entry you'll need to scroll through a fair pile to get to where BaCon should be, alphabetically speaking. And then, use the Rosetta site macros, there are quite a few of them, but you only need a few to make good entries. =={{header|BaCon}}== <lang freebasic>' Top line comment code more code</lang>
{{out}} <pre>prompt$ ./program ...</pre>
And that is about it. The Output: macro {{out}} and pre formatted output capture aren't strictly necessary, nor is the top line comment, but as Rosetta Code is an educational site, I find it helps getting people up to speed faster, and perhaps more interested in trying things out. The language tag is freebasic, as it seems to not bork up BaCon listings too badly. The highlighter is GeSHi based, and there are a few already built BASIC lexers to choose from. qbasic, for instance will convert some C types to uppercase, int to INT, so I ended up trying freebasic. Not all keywords work, and the highlighter is not full on BaCon powered, but that might change someday. Finding the entries and updating the lang markers shouldn't be too bad once (if) someone digs in and submits a BaCon GeSHi highlighter. Oh, and on your User login page, if you like bragging, add {{mylang|BaCon|Intermediate}} Or Expert, Beginner, Proficient, OK, Rusty, etc, as to how you rank yourself as a BaCon programmer. Peter, for that one, I'm not sure all the levels allowed, but Author would look pretty cool. And one final note; to all, Rosetta Code is a wiki site. Be bold, go ahead and fix any entries you find that can be made better, to show a more powerful BaCon construct or idiom, etc. Do not let a less than optimal entry sit there "because someone might be offended having the code changed". Along with that; all the entries to Rosetta Code fall under a free software license, so these entries need to be free and clear of infringement (no fair posting other people's work that isn't licensed for such use). Cheers, Brian
|
|
|
Post by Pjot on Feb 20, 2017 21:55:12 GMT 1
Thanks Brian, Well, that is exactly what I would be afraid of... ...reason being that some entries may have worked on for quite a few hours, and one can take pride in finding a solution at all. Changing code could simply wipe out all that work. Next to that, when to declare an entry not 'optimal'? Certain code may look ugly, but it may perform the task in 10 msecs, while some other version looks readable and maintainable, while the execution time may take up to 10 minutes. Or one program takes approx. 60 lines to get the solution, another one takes 30 lines but with a performance penalty. Looking at your entry for the ordered words, it works fine. My implementation below is a about 60% your size, it uses the delimited strings which makes the code understandable (IMHO), but is just a few msecs slower. (BTW I ran into an issue with SPLIT, please run my entry with an updated 3.5.2 version). Hope you don't get me wrong, as I really appreciate the initiative! I am only trying to avoid certain kind of discussions which we have seen at the BP site. It would only result into a bad atmosphere and a lot of unhappy faces. Thanks again, Best regards Peter FUNCTION Detect_Ordered(word$)
LOCAL good, pos, length
SPLIT word$ BY 1 TO c$ SIZE length IF length <= 1 THEN RETURN TRUE FOR pos = 0 TO length-2 IF c$[pos] <= c$[pos+1] THEN INCR good ELSE BREAK NEXT RETURN NOT(good-(length-1))
END FUNCTION
IF AMOUNT(ARGUMENT$) = 2 THEN list$ = LOAD$(TOKEN$(ARGUMENT$, 2)) ELSE list$ = LOAD$("unixdict.txt")
FOR w$ IN list$ STEP NL$ IF Detect_Ordered(w$) THEN IF LEN(w$) > Max_Len THEN Max_Len = LEN(w$) list$ = w$ ELIF LEN(w$) = Max_Len THEN list$ = APPEND$(list$, 0, w$) ENDIF ENDIF NEXT
PRINT REPLACE$(list$, " ", NL$)
PS the Palindrome program can be done in a very short way.
|
|
|
Post by btiffin on Feb 21, 2017 20:51:55 GMT 1
Not in the slightest, Peter. And you are right about leaving working solutions alone, to avoid potential conflict and possibly trivializing someone's hard efforts. Seeing as this one was my original, I'm about to update the Ordered words entry with your copy, as it highlights some important features of BaCon. I have no qualms with updating it to illuminate readers on the unique features in BaCon, but I appreciate the fact (more than I would have initially realized) that you pointed out a different solution here and didn't just overwrite the current entry. And yes, I bumped into the SPLIT issue with single character strings when I first tried your cut, latest update from Fossil fixes things nicely. Have good, make well, Brian P.S. You got made me curious to explore some things with SPLIT BY nr. Should BaCon spin on SPLIT BY 0 as a programming error, or should it emit a runtime error message? I didn't want to call it a bug, as I'd be willing to accept that SPLIT BY 0 is a programming error that can cause an internal infinite loop.
|
|
|
Post by btiffin on Feb 22, 2017 7:53:44 GMT 1
I just added rosettacode.org/wiki/Unix/ls#BaCon but I'm not that familiar with delimited strings yet, and I wonder if that routine might bork on filenames with some as yet untested names containing unbalanced quotes, spaces and/or backslashes. If it's wrong (and this to everybody), post a better copy here so I can fix it, or go ahead and make an edit. Cheers, Brian
|
|
|
Post by Pjot on Feb 22, 2017 21:56:26 GMT 1
P.S. You got made me curious to explore some things with SPLIT BY nr. Should BaCon spin on SPLIT BY 0 as a programming error, or should it emit a runtime error message? I didn't want to call it a bug, as I'd be willing to accept that SPLIT BY 0 is a programming error that can cause an internal infinite loop. Well, good question - it typically is one of those twilight zone situations where a decision needs to be made. Usually, a silent infinite loop doesn't help the end user a lot. When programming plain C, one ends up in such situations often. But this is BaCon. We could do one of the following: - Emit error during runtime, about the required value for BY being 1 or higher
- No error, but continue and skip the actual SPLITting completely - the value is 0 after all
- Leave it as it is
I am happy to hear your preferred approach on this matter Regards Peter
|
|
|
Post by Pjot on Feb 22, 2017 22:14:00 GMT 1
I wonder if that routine might bork on filenames with some as yet untested names containing unbalanced quotes, spaces and/or backslashes. If it's wrong (and this to everybody), post a better copy here so I can fix it, or go ahead and make an edit. Cheers, Brian Frankly, I would change your whole program, so it uses REPEAT/UNTIL. It saves us from the extra GETFILE. Also, why count the files? I do like your 'FOR..IN SORT$' construct a lot Regarding the issue of spaces, we should use a delimited list with a delimiter which may not occur in a file name of the current directory. This could be the "/" sign, which only is used for directories. Note that the FOR..IN now also needs a STEP. The adapted program below. Feel free to adapt it further... OPEN CURDIR$ FOR DIRECTORY AS mydir
REPEAT GETFILE myfile$ FROM mydir IF LEFT$(myfile$, 1) != "." AND LEN(myfile$) THEN files$ = APPEND$(files$, 0, myfile$, "/") ENDIF UNTIL NOT(LEN(myfile$))
CLOSE DIRECTORY mydir
FOR f$ IN SORT$(files$, "/") STEP "/" PRINT f$ NEXT
|
|