Re: future? Please Read Jakob's Post
Whether you agree or not, please read Jakob's post. It's a good read and puts forth many good questions and observations. I think a lot of us are concerned about the future of PicoLisp. I think it may be the Holy Grail, but I'm not sure ;-) On Tue, Feb 21, 2017 at 09:12:29PM +0100, Jakob Eriksson wrote: On 2017-02-21 20:18, andr...@itship.ch wrote: Online repositories like https://github.com/taij33n/picolisp and https://bitbucket.org/mmamkin/picolisp are not mere personal forks, but up to date clones of the official release at http://software-lab.de/picoLisp.tgz Both taij33n and mmamkin are core members of the picolisp community. So, the github and bitbucket are mirrors, basically. Petr, would it help if we would link and describe those repositories prominently on picolisp.com ? You are not asking me, but I say no. Or do you think people don't go first to our website, but find it directly on github/bitbucket and are turned away when they see "0 contributors" there? Very very true. They also notice that there is no presence on StackOverflow. Even very very obscure stuff has loads of presence on StackOverflow, and Stackoverflow basically rules Google. If it's about programming and not on Stackoverflow, it basically does not exist. Maybe putting a prominent note into the readme at github/bitbucket could improve this a bit... No. It won't. It really will not. For years, PicoLisp used to be hosted in such a online recommunity, actually at Google Code. Yes, but Google Code was no Github. Github is the singularity of open source development. (As much as I dislike FB but hear me out...) Google Code = Myspace, Github = Facebook It's like "yeah, we did this social network thing before. "Our band had a page on MySPACE (=Google Code) so this Facebook (=Github) thing is totally useless." There are two main reasons why PicoLisp development is not anymore managed over such a service: 1) Google Code closed down. Yes, its unlikely that this will happen soon with Github, but such offerings from big commercial companies are always up to the moods and motivations of the company, which can change suddenly. As a user, you're their asset, not the other way around. True, you are their asset. But if Github closes down, how hard can it be to migrate to something else? The philosophy of PicoLisp is to stay in control, for long-term stability, instead of short-term comfort by introducing dependencies. Now we are getting to the core of your argument. You know who else are dependencies? People. Users. Contributors. Other software. Yes, PicoLisp can stay core. It's finished. Of course it can't be anything else but finished if you won't let it! Is it a Bonsai tree in a very small pot or is it a Scalpel? Let your child free! Let the Scalpel out in the world and let it cut and slash. Yes, there is bound to be cuts and bloodshed here and there. But scalpels still mainly do good in the world. Picolisp is 30 years old. It's time it met friends, got drunk, got laid, and went to bad neighborhoods. All the young people with their strange loud "rock music" and long hair is on Github now. 2) In case of PicoLisp, the benefits such services bring (except more visibility) are actually not needed for core PicoLisp. For reason B), because... B) PicoLisp is finished software It is old (over 30 years), well tested (in real world usage), stable and secure. Still though, 30 years ago it did not run on Linux, did it. The world is not static. Much more knowledge, both programmer experience and usage experience, has already gone into PicoLisp compared to all those fashionable young projects which mostly just were started very few years ago. Yes, it has. It also went a lot of work into Cuneiform, probably more than ReactJS. I mean, Gilgamesh was even written in it! But if something isn't in use, and living, work doesn't matter. We have 4 types of issues with picolisp: 1) Programmers does not see how to do something (easily). Does it wrong or demands a feature. Someone (nearly always Regenaxer, we need to improve here as a community) invests time to explain the guy how it can be easily done with x,y. Nearly all issues fall into this type. Regenaxer does not scale - these things are a PERFECT fit for Stackoverflow. Actually, some of these Q/A sessions could probably even be input into SO after the fact. 2) Some incompatibilities on unusual platforms (e.g. running PicoLisp on BSD or Solaris) - usually fixed within hours or days by the guy who asked and by the community, often even without involvement of Regenaxer. There still is no Windows port. There is still no Browser (asm.js) port. 3) Someone comes up with a request for a feature for special use case which really doesn't fall into type 1), e.g. Mike/tankfeeder came up with requirements for some special functions to do his expert algorithm and crypto stuff. Such requests are acknowledged and implemented by Regenaxer
Re: Building functions with dynamic scope
Thank you. I'll check some evening this week and see if this subject is adequately covered on the wiki, and try to incorporate this in if it is not. On 02/21/2017 10:13 AM, Alexander Burger wrote: > Hi Christopher, > >> (de make-adder (N) (list '(X) (list '+ 'X N))) >> >> That works, but I was wondering if there was some more readable way to >> do it. > > Well, the standard candidate for that purpose is 'curry' (though we learned > that > this function name is a bit unlucky ;) > >(de make-adder (N) > (curry (N) > (X) (+ X N) ) ) > > In this call, 'N' is kept in a closure, allowing it to be changed while the > generated function runs: > >(make-adder 7) >-> ((X) (job '((N . 7)) (+ X N))) > > This is here not necessary, thus 'curry' allows you to tell it when > values are constant by using pattern variables, here '@N': > >(de make-adder (@N) > (curry (@N) > (X) (+ X @N)) ) > >(make-adder 7) >-> ((X) (+ X 7)) > > > Another option (in addition to your direct 'list'ing, is 'fill' > >(de make-adder (N) > (fill '((X) (+ X N)) 'N) ) > >(make-adder 7) >-> ((X) (+ X 7)) > > ♪♫ Alex > -- Christopher Howard, Computer Assistant Alaska Satellite Internet 3239 La Ree Way, Fairbanks, AK 99709 907-451-0088 or 888-396-5623 (toll free) fax: 888-260-3584 mailto:christop...@alaskasi.com http://www.alaskasatelliteinternet.com -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: future?
On 2017-02-21 20:18, andr...@itship.ch wrote: > > Online repositories like https://github.com/taij33n/picolisp and > https://bitbucket.org/mmamkin/picolisp are not mere personal forks, but > up to date clones of the official release at > http://software-lab.de/picoLisp.tgz > Both taij33n and mmamkin are core members of the picolisp community. So, the github and bitbucket are mirrors, basically. > Petr, would it help if we would link and describe those repositories > prominently on picolisp.com ? You are not asking me, but I say no. > Or do you think people don't go first to our website, but find it > directly on github/bitbucket and are turned away when they see "0 > contributors" there? Very very true. They also notice that there is no presence on StackOverflow. Even very very obscure stuff has loads of presence on StackOverflow, and Stackoverflow basically rules Google. If it's about programming and not on Stackoverflow, it basically does not exist. > Maybe putting a prominent note into the readme at github/bitbucket could > improve this a bit... No. It won't. It really will not. > For years, PicoLisp used to be hosted in such a online recommunity, > actually at Google Code. Yes, but Google Code was no Github. Github is the singularity of open source development. (As much as I dislike FB but hear me out...) Google Code = Myspace, Github = Facebook It's like "yeah, we did this social network thing before. "Our band had a page on MySPACE (=Google Code) so this Facebook (=Github) thing is totally useless." > There are two main reasons why PicoLisp development is not anymore > managed over such a service: > > 1) Google Code closed down. Yes, its unlikely that this will happen soon > with Github, but such offerings from big commercial companies are always > up to the moods and motivations of the company, which can change suddenly. > As a user, you're their asset, not the other way around. True, you are their asset. But if Github closes down, how hard can it be to migrate to something else? > The philosophy of PicoLisp is to stay in control, for long-term > stability, instead of short-term comfort by introducing dependencies. Now we are getting to the core of your argument. You know who else are dependencies? People. Users. Contributors. Other software. Yes, PicoLisp can stay core. It's finished. Of course it can't be anything else but finished if you won't let it! Is it a Bonsai tree in a very small pot or is it a Scalpel? Let your child free! Let the Scalpel out in the world and let it cut and slash. Yes, there is bound to be cuts and bloodshed here and there. But scalpels still mainly do good in the world. Picolisp is 30 years old. It's time it met friends, got drunk, got laid, and went to bad neighborhoods. All the young people with their strange loud "rock music" and long hair is on Github now. > > 2) In case of PicoLisp, the benefits such services bring (except more > visibility) are actually not needed for core PicoLisp. For reason B), > because... > > B) PicoLisp is finished software > It is old (over 30 years), well tested (in real world usage), stable and > secure. Still though, 30 years ago it did not run on Linux, did it. The world is not static. > Much more knowledge, both programmer experience and usage experience, > has already gone into PicoLisp compared to all those fashionable young > projects which mostly just were started very few years ago. Yes, it has. It also went a lot of work into Cuneiform, probably more than ReactJS. I mean, Gilgamesh was even written in it! But if something isn't in use, and living, work doesn't matter. > We have 4 types of issues with picolisp: > 1) Programmers does not see how to do something (easily). Does it wrong > or demands a feature. > Someone (nearly always Regenaxer, we need to improve here as a > community) invests time to explain the guy how it can be easily done > with x,y. > Nearly all issues fall into this type. Regenaxer does not scale - these things are a PERFECT fit for Stackoverflow. Actually, some of these Q/A sessions could probably even be input into SO after the fact. > 2) Some incompatibilities on unusual platforms (e.g. running PicoLisp on > BSD or Solaris) - usually fixed within hours or days by the guy who > asked and by the community, often even without involvement of Regenaxer. There still is no Windows port. There is still no Browser (asm.js) port. > 3) Someone comes up with a request for a feature for special use case > which really doesn't fall into type 1), e.g. Mike/tankfeeder came up > with requirements for some special functions to do his expert algorithm > and crypto stuff. > Such requests are acknowledged and implemented by Regenaxer in few hours > or few days. Usually this all happens in IRC, or in mailing list. This is a super power. Should be wider advertised... IMHO Regenaxer is wasting a golden opportunity by not advertising his services on Github and
Re: Building functions with dynamic scope
Hi Christopher, > (de make-adder (N) (list '(X) (list '+ 'X N))) > > That works, but I was wondering if there was some more readable way to > do it. Well, the standard candidate for that purpose is 'curry' (though we learned that this function name is a bit unlucky ;) (de make-adder (N) (curry (N) (X) (+ X N) ) ) In this call, 'N' is kept in a closure, allowing it to be changed while the generated function runs: (make-adder 7) -> ((X) (job '((N . 7)) (+ X N))) This is here not necessary, thus 'curry' allows you to tell it when values are constant by using pattern variables, here '@N': (de make-adder (@N) (curry (@N) (X) (+ X @N)) ) (make-adder 7) -> ((X) (+ X 7)) Another option (in addition to your direct 'list'ing, is 'fill' (de make-adder (N) (fill '((X) (+ X N)) 'N) ) (make-adder 7) -> ((X) (+ X 7)) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Building functions with dynamic scope
Hi list. Earlier I had a bit of trouble figuring out how to do function construction with dynamic scoping, i.e., what would "normally" be (de make-adder (N) '((X) (+ X N))) I figured out I could do (de make-adder (N) (list '(X) (list '+ 'X N))) That works, but I was wondering if there was some more readable way to do it. -- Christopher Howard, Computer Assistant Alaska Satellite Internet 3239 La Ree Way, Fairbanks, AK 99709 907-451-0088 or 888-396-5623 (toll free) fax: 888-260-3584 mailto:christop...@alaskasi.com http://www.alaskasatelliteinternet.com -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: help with global replace in text file/list of bytes
I've converted all of my filters to use in/out and have made the above virtually identical to that Rosetta Code example and the result is now.virtually instantaneousjust for the cost of a couple of temporary files. The difference is remarkable and again thank you both for steering me in this direction. (de lchg (From To Ipth Opth) (out Opth (in Ipth (while (echo From) (prin To) On 21 February 2017 at 15:20, deanwrote: > PS ..yes that Rosetta Code example is close to what I'm after. > > On 21 February 2017 at 15:19, dean wrote: > >> Hi Andreas >> >Do you really need to load all the stuff into RAM? >> No...I was originally using in/out >> and will go back to trying that for each filter. >> >> re the improvements...yes I understand all all of those...thank you. >> >exactly the same structure as in ram. >> Amazing and I'll bear that in mind. >> >> >I hope this helps... >> Yes it does and thank you very much >> >> Hi Joe >> >1. Your picolisp code is becoming easier to read. >> That's very kind...thank you...I am trying :) >> >> >3. Why do you need to work with bytes vs chars? >> Good question...Initially I have some >130 asci characters. >> Reading them as such is problematic but viewing them as bytes >> and changing those >asci 130 solves the problem. >> As the data is in bytes after such conversion I thought it might be >> more efficient to keep them that way but after >> your question, >> Rosetta Code example >> and Andreas' advice re confining things to in/out >> maybe not. >> I'll have a go trying to incorporate the above advice and example >> and report back. It might take me a while. >> >> Thank you both very much for your help. >> Best Regards >> Dean >> >> On 21 February 2017 at 13:14, Joe Bogner wrote: >> >>> After trying to figure it out myself for a few minutes, I remembered to >>> check rosettacode (wonderful resource). This is probably close to what you >>> need: http://rosettacode.org/wiki/Globally_replace_text_in_s >>> everal_files#PicoLisp >>> >>> On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner wrote: >>> Hi dean, I experimented with this problem for a few minutes and didn't come up with anything worth posting. A few comments though: 1. Your picolisp code is becoming easier to read. Nice work! 2. My initial thought was to split the input into words and replace sublists, however it looks like you don't have a word delimiter (typically a space)...Since you need to be able to substitute "fl ow" with "flow". As a result, the best I came up with is something similar (looping through characters and testing the replacement) 3. Why do you need to work with bytes vs chars? (mapcar char (chop Sfrom)) ? On Tue, Feb 21, 2017 at 3:37 AM, dean wrote: > I need to globally replace certain words in a text file and because > I need to process it a byte at a time initially...I'm inputting > processed list of bytes into the global replace function "lchg" > (and others) like this. > > (lbytes_to_fl Cleaned_txt_pth >(lchg "fl ow" "flow" >(fltr2 >(fltr1 > (fl_to_lbytes Txt_pth) > > The other filters seem ok but this one is slow (most likely my > algorithm/general approach :)) and any help to > speed things up would be much appreciated. > > (de lchg (Sfrom Sto Lbytes) >(make > (let > (X 0 > B NIL > Lfrom (mapcar char (chop Sfrom)) > Lto (mapcar char (chop Sto)) > First_from_ch (car Lfrom) > Len_from-1 (- (length Lfrom) 1) > Len_lbytes (length Lbytes) ) > (until (<= (length Lbytes) X) > (inc 'X) > (setq B (get Lbytes X)) > (if (= B First_from_ch) >(prog > (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) > (prog > (for MatchB Lto >(link MatchB) ) > (inc 'X Len_from-1) ) > (link B) ) ) >(link B) ) ) ) ) ) > >(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 > > Here's "lchg" in action... > > : (setq L (chop "ab fl ow flow fl ow yz")) > -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " > " "o" "w" " " "y" "z") > : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L > -> "ab flow flow flow yz" > > >>> >> >
Re: help with global replace in text file/list of bytes
PS ..yes that Rosetta Code example is close to what I'm after. On 21 February 2017 at 15:19, deanwrote: > Hi Andreas > >Do you really need to load all the stuff into RAM? > No...I was originally using in/out > and will go back to trying that for each filter. > > re the improvements...yes I understand all all of those...thank you. > >exactly the same structure as in ram. > Amazing and I'll bear that in mind. > > >I hope this helps... > Yes it does and thank you very much > > Hi Joe > >1. Your picolisp code is becoming easier to read. > That's very kind...thank you...I am trying :) > > >3. Why do you need to work with bytes vs chars? > Good question...Initially I have some >130 asci characters. > Reading them as such is problematic but viewing them as bytes > and changing those >asci 130 solves the problem. > As the data is in bytes after such conversion I thought it might be > more efficient to keep them that way but after > your question, > Rosetta Code example > and Andreas' advice re confining things to in/out > maybe not. > I'll have a go trying to incorporate the above advice and example > and report back. It might take me a while. > > Thank you both very much for your help. > Best Regards > Dean > > On 21 February 2017 at 13:14, Joe Bogner wrote: > >> After trying to figure it out myself for a few minutes, I remembered to >> check rosettacode (wonderful resource). This is probably close to what you >> need: http://rosettacode.org/wiki/Globally_replace_text_in_s >> everal_files#PicoLisp >> >> On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner wrote: >> >>> Hi dean, >>> >>> I experimented with this problem for a few minutes and didn't come up >>> with anything worth posting. A few comments though: >>> >>> 1. Your picolisp code is becoming easier to read. Nice work! >>> 2. My initial thought was to split the input into words and replace >>> sublists, however it looks like you don't have a word delimiter (typically >>> a space)...Since you need to be able to substitute "fl ow" with "flow". As >>> a result, the best I came up with is something similar (looping through >>> characters and testing the replacement) >>> 3. Why do you need to work with bytes vs chars? (mapcar char (chop >>> Sfrom)) ? >>> >>> >>> >>> On Tue, Feb 21, 2017 at 3:37 AM, dean wrote: >>> I need to globally replace certain words in a text file and because I need to process it a byte at a time initially...I'm inputting processed list of bytes into the global replace function "lchg" (and others) like this. (lbytes_to_fl Cleaned_txt_pth (lchg "fl ow" "flow" (fltr2 (fltr1 (fl_to_lbytes Txt_pth) The other filters seem ok but this one is slow (most likely my algorithm/general approach :)) and any help to speed things up would be much appreciated. (de lchg (Sfrom Sto Lbytes) (make (let (X 0 B NIL Lfrom (mapcar char (chop Sfrom)) Lto (mapcar char (chop Sto)) First_from_ch (car Lfrom) Len_from-1 (- (length Lfrom) 1) Len_lbytes (length Lbytes) ) (until (<= (length Lbytes) X) (inc 'X) (setq B (get Lbytes X)) (if (= B First_from_ch) (prog (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) (prog (for MatchB Lto (link MatchB) ) (inc 'X Len_from-1) ) (link B) ) ) (link B) ) ) ) ) ) (de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 Here's "lchg" in action... : (setq L (chop "ab fl ow flow fl ow yz")) -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " "o" "w" " " "y" "z") : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L -> "ab flow flow flow yz" >>> >> >
Re: help with global replace in text file/list of bytes
Hi Andreas >Do you really need to load all the stuff into RAM? No...I was originally using in/out and will go back to trying that for each filter. re the improvements...yes I understand all all of those...thank you. >exactly the same structure as in ram. Amazing and I'll bear that in mind. >I hope this helps... Yes it does and thank you very much Hi Joe >1. Your picolisp code is becoming easier to read. That's very kind...thank you...I am trying :) >3. Why do you need to work with bytes vs chars? Good question...Initially I have some >130 asci characters. Reading them as such is problematic but viewing them as bytes and changing those >asci 130 solves the problem. As the data is in bytes after such conversion I thought it might be more efficient to keep them that way but after your question, Rosetta Code example and Andreas' advice re confining things to in/out ...maybe not. I'll have a go trying to incorporate the above advice and example and report back. It might take me a while. Thank you both very much for your help. Best Regards Dean On 21 February 2017 at 13:14, Joe Bognerwrote: > After trying to figure it out myself for a few minutes, I remembered to > check rosettacode (wonderful resource). This is probably close to what you > need: http://rosettacode.org/wiki/Globally_replace_text_in_ > several_files#PicoLisp > > On Tue, Feb 21, 2017 at 8:08 AM, Joe Bogner wrote: > >> Hi dean, >> >> I experimented with this problem for a few minutes and didn't come up >> with anything worth posting. A few comments though: >> >> 1. Your picolisp code is becoming easier to read. Nice work! >> 2. My initial thought was to split the input into words and replace >> sublists, however it looks like you don't have a word delimiter (typically >> a space)...Since you need to be able to substitute "fl ow" with "flow". As >> a result, the best I came up with is something similar (looping through >> characters and testing the replacement) >> 3. Why do you need to work with bytes vs chars? (mapcar char (chop >> Sfrom)) ? >> >> >> >> On Tue, Feb 21, 2017 at 3:37 AM, dean wrote: >> >>> I need to globally replace certain words in a text file and because >>> I need to process it a byte at a time initially...I'm inputting >>> processed list of bytes into the global replace function "lchg" >>> (and others) like this. >>> >>> (lbytes_to_fl Cleaned_txt_pth >>>(lchg "fl ow" "flow" >>>(fltr2 >>>(fltr1 >>> (fl_to_lbytes Txt_pth) >>> >>> The other filters seem ok but this one is slow (most likely my >>> algorithm/general approach :)) and any help to >>> speed things up would be much appreciated. >>> >>> (de lchg (Sfrom Sto Lbytes) >>>(make >>> (let >>> (X 0 >>> B NIL >>> Lfrom (mapcar char (chop Sfrom)) >>> Lto (mapcar char (chop Sto)) >>> First_from_ch (car Lfrom) >>> Len_from-1 (- (length Lfrom) 1) >>> Len_lbytes (length Lbytes) ) >>> (until (<= (length Lbytes) X) >>> (inc 'X) >>> (setq B (get Lbytes X)) >>> (if (= B First_from_ch) >>>(prog >>> (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) >>> (prog >>> (for MatchB Lto >>>(link MatchB) ) >>> (inc 'X Len_from-1) ) >>> (link B) ) ) >>>(link B) ) ) ) ) ) >>> >>>(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 >>> >>> Here's "lchg" in action... >>> >>> : (setq L (chop "ab fl ow flow fl ow yz")) >>> -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " >>> "o" "w" " " "y" "z") >>> : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L >>> -> "ab flow flow flow yz" >>> >>> >> >
Re: Future of PicoLisp?
Hi all My previous message somehow got broken, half the text is missing. Please read it here: http://www.beneroth.ch/pil/picolisp-is-finished.html Thanks, beneroth - Original Message - From: andr...@itship.ch [mailto:andr...@itship.ch] To: picolisp@software-lab.de Sent: Tue, 21 Feb 2017 14:26:53 +0100 Subject: Re: Future of PicoLisp?
Re: Future of PicoLisp?
Hi Petr Many thanks for your participation and outside view. Such comments are very valuable to us, as those topics are hard to see from the inside. I believe those feelings are triggered by mainly two source factors: A) presentation of picolisp information B) the (rather unusual) state of the picolisp project A) First and foremost, we as community need to streamline our presence more, probably mainly by making things more clear on picolisp.com. We should also more prominently point to the IRC channel, that is where we meet daily. Online repositories like https://github.com/taij33n/picolisp and https://bitbucket.org/mmamkin/picolisp are not mere personal forks, but up to date clones of the official release at http://software-lab.de/picoLisp.tgz Both taij33n and mmamkin are core members of the picolisp community. Petr, would it help if we would link and describe those repositories prominently on picolisp.com ? Or do you think people don't go first to our website, but find it directly on github/bitbucket and are turned of when they see "0 contributors" there? Maybe putting a prominent note into the readme at github/bitbucket could improve this a bit... For years, PicoLisp used to be hosted in such a online community, actually at Google Code. There are two main reasons why PicoLisp development is not anymore managed over such a service: 1) Google Code closed down. Yes, its unlikely that this will happen soon with Github, but such offerings from big commercial companies are always up to the moods and motivations of the company, which can change suddenly
Re: help with global replace in text file/list of bytes
After trying to figure it out myself for a few minutes, I remembered to check rosettacode (wonderful resource). This is probably close to what you need: http://rosettacode.org/wiki/Globally_replace_text_in_several_files#PicoLisp On Tue, Feb 21, 2017 at 8:08 AM, Joe Bognerwrote: > Hi dean, > > I experimented with this problem for a few minutes and didn't come up with > anything worth posting. A few comments though: > > 1. Your picolisp code is becoming easier to read. Nice work! > 2. My initial thought was to split the input into words and replace > sublists, however it looks like you don't have a word delimiter (typically > a space)...Since you need to be able to substitute "fl ow" with "flow". As > a result, the best I came up with is something similar (looping through > characters and testing the replacement) > 3. Why do you need to work with bytes vs chars? (mapcar char (chop > Sfrom)) ? > > > > On Tue, Feb 21, 2017 at 3:37 AM, dean wrote: > >> I need to globally replace certain words in a text file and because >> I need to process it a byte at a time initially...I'm inputting >> processed list of bytes into the global replace function "lchg" >> (and others) like this. >> >> (lbytes_to_fl Cleaned_txt_pth >>(lchg "fl ow" "flow" >>(fltr2 >>(fltr1 >> (fl_to_lbytes Txt_pth) >> >> The other filters seem ok but this one is slow (most likely my >> algorithm/general approach :)) and any help to >> speed things up would be much appreciated. >> >> (de lchg (Sfrom Sto Lbytes) >>(make >> (let >> (X 0 >> B NIL >> Lfrom (mapcar char (chop Sfrom)) >> Lto (mapcar char (chop Sto)) >> First_from_ch (car Lfrom) >> Len_from-1 (- (length Lfrom) 1) >> Len_lbytes (length Lbytes) ) >> (until (<= (length Lbytes) X) >> (inc 'X) >> (setq B (get Lbytes X)) >> (if (= B First_from_ch) >>(prog >> (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) >> (prog >> (for MatchB Lto >>(link MatchB) ) >> (inc 'X Len_from-1) ) >> (link B) ) ) >>(link B) ) ) ) ) ) >> >>(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 >> >> Here's "lchg" in action... >> >> : (setq L (chop "ab fl ow flow fl ow yz")) >> -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " >> "o" "w" " " "y" "z") >> : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L >> -> "ab flow flow flow yz" >> >> >
Re: help with global replace in text file/list of bytes
Hi dean, I experimented with this problem for a few minutes and didn't come up with anything worth posting. A few comments though: 1. Your picolisp code is becoming easier to read. Nice work! 2. My initial thought was to split the input into words and replace sublists, however it looks like you don't have a word delimiter (typically a space)...Since you need to be able to substitute "fl ow" with "flow". As a result, the best I came up with is something similar (looping through characters and testing the replacement) 3. Why do you need to work with bytes vs chars? (mapcar char (chop Sfrom)) ? On Tue, Feb 21, 2017 at 3:37 AM, deanwrote: > I need to globally replace certain words in a text file and because > I need to process it a byte at a time initially...I'm inputting > processed list of bytes into the global replace function "lchg" > (and others) like this. > > (lbytes_to_fl Cleaned_txt_pth >(lchg "fl ow" "flow" >(fltr2 >(fltr1 > (fl_to_lbytes Txt_pth) > > The other filters seem ok but this one is slow (most likely my > algorithm/general approach :)) and any help to > speed things up would be much appreciated. > > (de lchg (Sfrom Sto Lbytes) >(make > (let > (X 0 > B NIL > Lfrom (mapcar char (chop Sfrom)) > Lto (mapcar char (chop Sto)) > First_from_ch (car Lfrom) > Len_from-1 (- (length Lfrom) 1) > Len_lbytes (length Lbytes) ) > (until (<= (length Lbytes) X) > (inc 'X) > (setq B (get Lbytes X)) > (if (= B First_from_ch) >(prog > (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) > (prog > (for MatchB Lto >(link MatchB) ) > (inc 'X Len_from-1) ) > (link B) ) ) >(link B) ) ) ) ) ) > >(de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 > > Here's "lchg" in action... > > : (setq L (chop "ab fl ow flow fl ow yz")) > -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " > "o" "w" " " "y" "z") > : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L > -> "ab flow flow flow yz" > >
RE: help with global replace in text file/list of bytes
Hi dean Do you really need to load all the stuff into RAM? Working in stream, e.g. with (in) (out) and (char) (called without arguments) or (rd) (binary read) needs slightly different software design, but would most likely be faster. Also, (chop) is a rather expensive function (because it has to reserve new memory), probably you can easily improve performance by chopping all input once during initial reading, and then store the content as lists instead of strings which you chop in every filter function. Maybe you can identify other areas where you could keep some stuff in variables instead of doing the same thing multiple times. Then make sure that you don't have any code multiple times lying around, refactor common steps into functions. In picolisp the source code is exactly the same structure as the RAM representation and execution flow, it follows that shorter code usually results in better performance. I hope this helps, good luck and have fun! Regards, beneroth
help with global replace in text file/list of bytes
I need to globally replace certain words in a text file and because I need to process it a byte at a time initially...I'm inputting processed list of bytes into the global replace function "lchg" (and others) like this. (lbytes_to_fl Cleaned_txt_pth (lchg "fl ow" "flow" (fltr2 (fltr1 (fl_to_lbytes Txt_pth) The other filters seem ok but this one is slow (most likely my algorithm/general approach :)) and any help to speed things up would be much appreciated. (de lchg (Sfrom Sto Lbytes) (make (let (X 0 B NIL Lfrom (mapcar char (chop Sfrom)) Lto (mapcar char (chop Sto)) First_from_ch (car Lfrom) Len_from-1 (- (length Lfrom) 1) Len_lbytes (length Lbytes) ) (until (<= (length Lbytes) X) (inc 'X) (setq B (get Lbytes X)) (if (= B First_from_ch) (prog (if (= (slice Lbytes X (+ X Len_from-1)) Lfrom) (prog (for MatchB Lto (link MatchB) ) (inc 'X Len_from-1) ) (link B) ) ) (link B) ) ) ) ) ) (de slice (Lst I K) (head (inc (- K I)) (nth Lst I)) ) #99 Here's "lchg" in action... : (setq L (chop "ab fl ow flow fl ow yz")) -> ("a" "b" " " "f" "l" " " "o" "w" " " "f" "l" "o" "w" " " "f" "l" " " "o" "w" " " "y" "z") : (pack (mapcar char (lchg "fl ow" "flow" (mapcar char L -> "ab flow flow flow yz"