#] #] ********************* #] "$d_Qndfs"'QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt' - #] change optr names to highest dimension version only, for [clarity, consistency] # www.BillHowell.ca 09Nov2021 initial # I need to "remove the crutches" of optrSyms that trap the programmer in low dimension # build a "symName helper" to select optrs & check they exist #**************************** # Table of Contents, generated with : # $ grep "^#] " "$d_Qndfs""QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt" | sed 's/^#\]/ /' # ********************* # ********************* #] Principles, planning valence will be key - which optrs fail at [high, low]er valence? first do strings.ndf # ********************* #] Tools extract IS expressions to remove : $ grep '^x' "$d_Qndfs"'QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt' replace words : $ find "???" -maxdepth 3 -name "*.html" | tr \\n \\0 | xargs -0 -IFILE grep -w -i --with-filename --line-number '^x' "FILE" | sed 's#:.*##' | sort -u $ find "???" -maxdepth 3 -name "*.html" | tr \\n \\0 | xargs -0 -IFILE grep -w -i --with-filename --line-number '^x' "FILE" | sed 's#:.*##' | sort -u # geany text editor regexpr search-replace to put in apos : put apo at end of words at end of lines, multiline mode : [ \t]*\n ' \n put apo between words : ([a-zA-Z0-1])([ \t]+)([a-zA-Z0-1]) \1'\2\3' # ********************* #] Work log #] 09Nov2021 list of optrOldNew replacements planned for throughout d_Qndfs #] see "$d_Qndfs"'QNial symbolOldNew.txt' for list I use temporary optrs [pinn_read_strL_fixer, replace_wordL] in 'QNial usrWkSpc symbol changes.ndf' For each ndf below : add apos : geany regexpr search ^([a-zA-Z0-9]+)([ \t].) replace \'\1\'\2 interesting, couldn't use ([\t].) ???? - Idiot! there were end-of-line spaces on most lines manually copy-past new optrNames from strings.ndf +-----+ strings.ndf : do this one first $ grep '^x' "$d_Qndfs"'QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt' | sed 's/^x\t\(.*\) IS OP .*/\1/' I didn't include because of uncertainty : 'chrLL_anyIn_strL' '' 'str_splitLftRgtTo_midIndxs_to_strL' '' 'subStr_insertBetweenThenLink_strL' '' 'chrL_cutEACH_strL' '' 'str_stripAllSpacesQ' '' 'str_stripSpacesAll' '' 'atomStrA_convertTo_str' '' 'ary_leafsTo_strs' '' 10Nov2021 +-----+ lists.ndf : $ grep '^y' "$d_Qndfs"'QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt' | sed 's/^y\t\(.*\) IS OP .*/\1/' do more with an older file : +-----+ file_ops.ndf : >> no changes, I should be using older files? - maybe later when non-core files are changed? I think I did that for strings, but not lists Compare older file with list below : "$d_Qndfs"'z_Archive/211106 07h40m19s file_ops.ndf' >> extensive changes to use of p[old, add, new, ovr] I need to revert "neutral" cases back to pth from p[old, add, new, ovr] >> now almost all optrNames must be changed $ grep '^z' "$d_Qndfs"'QNial [symbol, arg] changes/3_QNial symbol - draft listings to use for changes.txt' | sed 's/^z\t\(.*\) IS OP .*/\1/' +-----+ OK, ready to test [pinn_read_strL_fixer, replace_wordL] $ pinn_read_strL_fixer link d_Qndfs 'QNial symbolOldNew strings.txt' QNial symbolOldNew strings.txt $ ls -1 --directory '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS/' | sed "s|""$d_Qndfs""||" qnial> FOR sub WITH ('Bessel' '' 'Mindcode/' first host_result link 'find "$d_Qndfs""MindCode/" -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" ' $ find "$d_Qndfs" -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" $ find "$d_Qndfs"'MindCode/' -name "*.ndf" | grep --invert-match "z_Old\|z_Archive" $ find -type d -name "$d_Qndfs" | grep --invert-match "z_Old\|z_Archive" $ ls -1 --directory '/media/bill/Dell2/Website - raw/Qnial/MY_NDFS' | sed "s|""$d_Qndfs""||" #] 09Nov2021 'array, table.ndf' - many optrs [moved, renamed] here ********************* loaddefs link d_Qndfs 'array, table.ndf' As QNial is an array-oriented language, it has extremely powerful built-in capabilities. This obviates the need for most [chr, str, lst, tbl, etc] optrs. It is best to learn to work in as [high a dimension, deep a nesting] as practical (or won't learn) My work below comprises very simple arrangements for simple tasks, with some built-in checks. +-----+ TopLevel [in, is, check] tests of [array, table]s : [in, is] normally [o,l] (but can be faultL), check [faultL, null] atoms (atm) may be [bool, chr, cmplx, fault, int, real, phr, ?missing one or two?] isAtom IS atomic - see link d_Qtest 'QNial setup.ndf' : atm_inTopLevel_aryN IS OP atm aryN - boolean indication of whether atom is in first-level-only of aryN atmA_anyInTopLevel_aryN IS OP atmA aryN - boolean indication of whether any of atmA are in strA atmA_anyInTopLevel_aryA2 IS OP atmA aryA - boolean indication of whether any of atmA are in aryA will not match for nested parts of [atm, str]A - need a different optr, or upgrade this one itm_inTopLevel_aryN IS OP atm aryN - boolean indication of whether item is in first-level-only of aryN itmL_anyInTopLevel_aryN IS OP itmL aryN - boolean indication of whether any of atmA are in aryA because itmL_anyIn_aryN does NOT use grep, it easily handles '$.*/[\]^' characters, sub_inTopLevel_aryN IS OP sub aryN - true if sub is in aryS (simply array) 09Nov2021 this looks very inefficient! (don't know if it works yet) sub_anyInTopLevel_aryN IS OP sub aryN - returns true if ANY of sub are in aryN 09Nov2021 this looks very inefficient! (don't know if it works yet) +-------------------+ TopLevel position of [atm, itm, sub]s : itm_posnAInTopLevel_aryN IS OP itm aryN - position list (posnAryN) of itm in first level of aryN, or null itm MUST be an "element" of lst, eg (0 1) in ((0 1) 2 3 4 5), not in (0 1 2 3 4 5) itm_posn1stInTopLevel_aryN IS OP itm aryN - 1st posn of itm in aryN (closest to upper left corner), or null itm MUST be an "element" of aryN, eg (0 1) in ((0 1) 2 3 4 5), not in (0 1 2 3 4 5) Item1st is first item of subL sub_posnAInTopLevel_aryN IS OP sub aryN - ALL addr of sub deep within in array, null if not found sometimes fault? subL_posn1stItm1stInTopLevel_aryN IS OP subL aryN - 1st posn of 1st itm of subL in aryN returns initial 1st char positions for each subL, or a [null, error] 04Nov2021 NOT READY! only works with subL of atoms for now??! subL is a sequence of itms of aryN, eg ((0 1) 2) in ((0 1) 2 3 4 5), not in (0 1 2 3 4 5) subL_posnAAllInTopLevel_aryN IS OP subL aryN - posn of all subL, for all occurences of subL in aryN subLL_posnAItmAllIn_aryN IS OP aryN subLL - all itm positions for all occurences each subLL in aryN +-------------------+ [hold, add, strip, replace] - returns a list (doesn't split the list) : choose_region IS OP pointpairs array - select a region of an array aryL_join_vertical IS OP A - joins 2D arrays by "stacking-merging" each above next aryL_join_horizontal IS OP A - joins 2D arrays by "side-merging" each alongside next ary_replace_subAry IS OP ary subOld subNew - replaces occurences of an array component with another sequencer IS OP pointpair - generate indices to select a region of an array ary_LEAFAtmALLto_subAry IS OP ary subAry - returns an ary of same structure as ary, but all atoms of ary are replaced with subAry, handy for test standards, ready for post-replacements +-------------------+ split[Separate,[At[Front,End]], ] : +-------------------+ [cut, keep, take] - split up the array : +-------------------+ [sort, cull] : +-------------------+ [compare, convert] - array [, contents] to another [array, type] : ary_to_atomL IS OP ary - returns an atomL containing all contents of ary handy for nestAry [test, standard]s, - eg all [bool, chr, int, real, phrase, complex] ary atomA_restructSameAs_ary IS OP atomA ary - only effective for top-most structure of ary normally will be of use for noNestArys (non-nested) not recommended : [crude, inefficient] alternative to using [EACH, TWIG, LEAF, etc] transformers ary1_transStr_isSameStructAs_ary2 IS OP ary1 transStr ary2 - boolean indicating if ary[1,2] have same same structure by applying transformer transStr +-----+ Tables, titles table_build IS OP n_cols labld_data - process loaddef of table with column headers table_add_rowTitles IS OP tableData rowTitles - res ipsa loqitor table_add_colTitles IS OP tableData colTitles - res ipsa loqitor table_add_rowColTitles IS OP tableData rowTitles colTitles - common [row,col]Titles@0 colTitles overwrites newTable@(0 0), if null then newTable@(0 0) := rowTitles@0 table_remove_colTitles IS OP table - remove column titles from table table_remove_rowTitles IS OP table - remove column titles from table table_remove_rowColTitles IS OP table - remove column titles from table table_write IS OP titles - output labelled table tbl_selectRowsBy_col_key IS OP tbl col key - returns a table of selected rows +-----+ Database queries (sort of) ary_findIndxs_commonItems IS OP ary - finds indexs of common items in a ary aryL_commonKeyCullSort_aryCombinedOut IS OP listOfArys keyColIndxL - returns arrayList, sorted by common-keys, as per keyColIndxL aryL_extractMulplicate_subArys IS OP selectOp aryList - find mulplicates in aryN by selectOp actually, should work with any array type (in form of list), including aryNs 29May2021 - no good for general use, use aryL_commonKeyCullSort_aryCombinedOut +-----+ transformers - normal TRANSFORMERs, as well as "generalised transformer" (OPERATORs) aryInn_replaceWith_aryOut IS OP aryInn aryOut - useful for "general transformers" (optrs with optrPhrs) I was thinking of replacing [atom, str]s in nested arys at the time ... normally just use aryOut := aryInn, which won't help in transformers opPhr_ary_LEAFreplaceWith_aryStatic IS OP optrPhr ary aryStatic - LEAF_ary1aryStatic IS TRANSFORMER f OPERATION ary1aryStatic - # ********************* #] ndf files #] lists - old optrs 09Nov2021 # 24************************24 # List of operators, generated with : # $ grep "^#]" "$d_Qndfs""lists.ndf" | sed 's/^#\]/ /' # ********************* loaddefs link d_Qndfs 'lists.ndf' - many, if not most, string optrs are applicable to [atom, non-nested (simple)] lists +-------------------+ [in, is] tests of lists : isList IS OP lst - check if lst is a list y subLst_in_lst IS OP subLst lst - simple indication of whether a subLst is in lst y subLstL_anyIn_lst IS OP subLstL lst - returns true if ANY of subLstL are in lst +-------------------+ list checks : lst_checkIs IS OP lst - check if lst is a list lstL_checkIsAllFaults IS OP lstL - res ipsa loquitor lstL_checkIfAnyFaults IS OP lstL - res ipsa loquitor +-------------------+ Position of [itm, subLst, lstSeq, etc]s : y itm_posnLIn_lst IS OP itm lst - returns list of lstItem positions in lst lstItem MUST be an "element" of lst, eg (0 1) in ((0 1) 2 3 4 5), not in (0 1 2 3 4 5) y subLst_posnL1stItmIn_lst IS OP lst subLst - returns list of subLst positions in lst, or an error 04Nov2021 NOT READY! only works with subLst of atoms for now??! Item1st is first item of subLst y subLst_posnLLItmAllIn_lst IS OP lst subLst - returns list of subLst positions in Str y subLstL_posn1stL_lst IS OP lst subLstL - 1st item positions in Str, for all subLst returns initial 1st char positions for each subLst, or a [null, error] y subLstL_posnLLItmAllIn_lst IS OP lst subLstL - all subLst positions, for EACH subLst, in Str just returns initial char positions for each subLst, or a [null, error] +-------------------+ list [cut, keep] : itm_cut_lst IS OP itm lst - cut lst at each itm, omitting itm, returns a LIST! itm_cut_lstL IS OP lst itmL - cut a lst at each itm, omitting itm, returns a LIST! lstL_cutBy_itmL IS OP lstL itmL - cut each lstL by all itmL, omitting itmL, ??lists only (not arys)?? note that a character list is just a lst, but I use "itmL" to emphasize that each itm cuts lst_keep_itmL IS OP lst itmL - cut a lst at each itm, omitting itm, returns a LIST! lstL_keep_itmL IS OP lstL itmL - cut each lstL by including itmL, omitting non-itmL, ??lists only (not arys, maybe generalize to arrays (several years hence))?? note that a character list is just a lst, but I use "itmL" to emphasize that each itm cuts +-------------------+ lst_[cutBy, keep, split[Separate,[At[Front,End]]], specialised stuff]_[,sub]lst : y lst_splitSeparate_subLst IS OP lst subLst - subLst [splits lst, separate] y lst_splitSeparateRecurse_subLstL IS OP lst subLstL - recursively separate lst where subLst occurs, subLst separate y lst_splitAtEnd_subLst IS OP lst subLst - split lst where subLst occurs, subLst @end of each split y lst_splitAtFront_subLst IS OP lst subLst - splits lst at each point that subLst occurs subLst in lstLOut combined with next item y lst_splitAtFront_subLstL IS OP lst subLstL - splits lst at each point that an item of subLstL occurs each subLst in lstLOut at the front of following items 04Nov2021 corrupted? y lst_cutBy_subLst IS OP lst subLst - splits lst at each point that subLst occurs, omit subLst lst_splitLftRgtTo_midIndxs_lstL IS OP lst lstLft lstRgt - split lst, return [indxs, lstLst] y lst_replaceSubTo_lstL IS OP lst subLstOld subLstNew - splits lst at each subLstOld replace subLstOld with subLstNew y lst_cutByWidthTo_lstL IS OP lst Width - cut lst into lstings of equal length broken on word boundaries y lstL_replace_lst IS OP lstL subOld subNew - replace all subLstOld by subLstNew in lstL aryList_extractMulplicate_subArys IS OP selectOp lstL - find mulplicates in lstL by selectOp see d_Qroot 'setup.ndf' - works with lstLs, or any array type (in form of list) y lstL_selectOddNum_subLstL IS OP lstL - useful for inclusion in a list of lstL for [terminal, file] output y lst_subLsts_takeLenMatches_subLstPairs IS OP lst subLsts - return (lst = link subLstPairs) +-------------------+ list [add, strip, replace] parts - returns part of the list (doesn't split the list) : subLst_insertBetweenThenLink_lstL IS OP subLst lstL - link (insert subLst between lstL items) y lst_prepadWith_itm IS OP lst len itm - example: zero-prepadding numbers to get constant lst length if lst_length >= len, returns lst, often used for y lst_prepadWith_itm_toLength IS OP lst itm length - prepads lst with itms to get length y lst_postpadWith_itm_toLength IS OP lst itm length - postpads lst with itms to get length lst_strip_itm IS OP itm lst - remove itm from lst, standard QNial library lst_remove_subLst IS OP lst subLst - removes subLst from lst lst_repeatNtimesTo_lstL IS OP lst n - repeats lst n times lst_replace_subLst IS OP lst subOld subNew - substitutes subNew for subOld in lst lst_replaceAll_lstOld IS OP lst lstOld lstNew - lstOld is replaced by lstNew in lst y lst_stripAfterIncl_subLst IS OP lst subLst - extract to the 1st occurence of subLst, else return lst ? no good!!! y lst_stripBeforeIncl_subLst IS OP lst subLst -extract after the 1st occurence of subLst, else return null? ? no good!!! y lst_extractBetween_StrtEnd IS OP lstFull lstFront - extract between lstFront & lstEnd lst_extractBetween_StrtEnd IS OP lst lstStrt lstEndr - extracts subLsts between [lstStrt,lstEndr] screws up! - needs fixing... DUPLICATE OF lst_extractBetween_StrtEnd? lst_reduceTo_width IS OP lst1 sw - cut lst to fixed length, or pad end with spaces to make length winID_copyAllTextTo_poutNew IS OP winID pname - copy text of webPage and pre-pend to file see 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' I need an operator for intraPageLinks to TableOfContents (invocable by embedded executable) I need operators for conversions between [QNial, HTML, csv, loaddef] tables +-------------------+ [sort, cull] lists - listL_sortupOn1st IS OP ListOfLists - EACH sortup set of lists based on first list listL_sortupOn_col IS OP colNum ListOfLists - EACH sortup set of lists based on colNum lists_sortupCullOn1st IS OP ListOfLists - EACH [sortup,cull] set of lists based on first list Cull Definition - cull IS OPERATION A {­ grid A EACHLEFT in (A EACHLEFT find A) sublist A } listL_linkSortCullBy_aryCommonKeyIndexs IS OP listOfLists - finds indexs of common items for each list in listOfLists, can be used with a solitary list listL_linkSortCullBy_aryCommonKeyIndexs_tests IS y strPairL_sortCullUnique IS OP strPairL - sort, then cull to get a unique list of strPairs ordering matters : (str1 str2) ~= (str2 str1) strPairL_sortCullUnique IS OP strPairL - sort, then cull to get a unique list of strPairs ordering matters : (str1 str2) ~= (str2 str1) #] strings - old optrs 09Nov2021 #**************************** # List of operators, generated with : # $ grep "^#] " "$d_Qndfs""strings.ndf" | sed 's/^#\]/ /' # ********************* loaddefs link d_Qndfs 'strings.ndf' Many str [expr, optr, trans]s can be [derived from, generalised] to array equivalents 25Oct2021 half of this file was moved to lists.ndf a it was directly applicable to lists +-------------------+ [in, is] tests of strings : x chr_in_str IS OP chr str - boolean indication of whether chr is in str x chrL_anyIn_str IS OP chrL str - boolean indication of whether any of chrA are in strA because chrL_anyIn_str does NOT use grep, it easily handles '$.*/[\]^' characters, x chrLL_anyIn_strL IS OP chrL str - boolean indication of whether any of chrA are in strA x chrA_anyIn_strA IS OP chrA strA - boolean indication of whether any of chrA are in strA chrA may be [chr, str, ary with chr at top-most level (not str with matching chrs)] will not match for nested parts of [chr, str]A - need a different optr, or upgrade this one chrL_in_str_to_charrepL IS OP chrL str flag_chrs_include - returns charrepL [in, NOT in] use to produce a charrepL by [in,ex]cluding chrSet, eg program [symbol names, optrs, etc] charrepL shows that special chrs are in a [str, line] ?11Oct2021 str_isSpcTabs IS OP Str - test that string is entirely [space, tab] str_isOfSpcTabCrNl IS OP line - tests if a line is all "whitespace" [space, tab, CR, \n] str_isOf_chrSet IS OP str chrSet - true if all chrs in str are in chrSet str_checkIs IS OP str - check if str isstring strPairL_checkIs IS OP strPairL - check if strPairL is a list of pairs, each pair is two strings strPairL_checkIsUnique IS OP strPairL - check if strPairL is a UNIQUE list of strPairs [EACH str_checkIs, strOld EACHBOTH ~= strNew, = [cull, pass] strNew] x subStr_in_str IS OP Substr Str - simple indication of whether a Substr is in str x subStrL_anyIn_str IS OP subStrL str - returns true if ANY of subStrL are in str +-------------------+ string cleanup : str_surroundWithApos IS OP str - convert str to string with apostrophes, or if not a string return str_surroundWithAposAddTab IS OP str - convert str to string with apos & tab, or return input str_lastNonWhiteChr_position IS OP Str pos - retrieves the last non-whitespace character chrAsStr_toUpperCase IS OP chr - convert a character to upper case, (non-Unicode) chrAsStr_toLowerCase IS OP chr - convert a character to lower case, (non-Unicode) str_toUpperCase IS OP str - convert all letters in a string to upper case, (non-Unicode) str_toLowerCase IS OP str - convert all letters in a string to lower case, (non-Unicode) str_capitalize1stCharOnly IS OP str - capitalize 1st char of str, rest small, watch out for acronyms!, (non-Unicode) str_capitalize1stCharEachWord IS OP str - capitalise 1st char of each word, rest small, watch out for acronyms!, (non-Unicode) set_globalChrSet IS OP chrSet1 chrSet2 - redefine global chrSets[1,2] chrSets[1,2] are defined as globals to enhance the efficiency of chrSet operators!! note that one can link multiple charSets for g_chrSet[1,2], but must be in order, same shape chrAsStr_changeChrSet IS OP chrAsStr - return corresponding chrAsStr in newChrSet, or current chrAstr if no correspondance, must preset globals g_chrSet[1,2] chrL_changeChrSet IS OP chrL - change chrsAsStrs in chrL from g_chrSet1 to g_chrSet2 str_changeChrSet IS OP str oldChrSet newChrSet - change every oldChrSet in str to newChrSet str_swapChrSets IS OP str chrSet1 chrSet2 - change all chrSet1 in str to chrSet2, and visa-versa strURL_clean IS OP str - change all chrSet1 in str to chrSet2, and visa-versa +-------------------+ Position of [chrs, sub-strings, etc] : x chr_posnLIn_str IS OP str chr - posnL of chr in Str, or null x subStr_posn1stChrIn_str IS OP subStr str - 1st posn of 1stChr of Substr in Str, or null?? a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... x subStr_posnLLChrAllIn_str IS OP subStr str - posnLL of all itms of Substr in Str, or null a single position is returned as a solitary so it can be used in subsequent EACH expressions etc.... x subStrL_posn1stChrIn_str IS OP subStr str - all subStrL 1s chr positions, for EACH subStrL, in str returns initial 1st char positions for each subStr, or a [null, error] x subStrL_posnLLChrAllIn_str IS OP subStr str - all subStr positions, for EACH subStr, in Str just returns initial char positions for each subStr, or a [null, error] +-------------------+ str_split[Separate,[At[Front,End]], ] : The following were developed for strings, but are applicable to ?all? lists 25Oct2021 this section was pulled from strings.ndf x subStr_splitSeparate_str IS OP subStr str - subStr [splits str, separate] x subStrL_splitSeparateRecurse_str IS OP subStr str - recursively separate str where subStr occurs, subStr separate x subStr_splitAtEnd_str IS OP subStr str - split str where subStr occurs, subStr @end of each split x subStr_splitAtFront_str IS OP subStr str - splits str at each point that subStr occurs subStr in strLOut combined with next item x subStr_splitAtFront_strL IS OP subStr str - splits str at each point that an item of subStrL occurs each subStr in strLOut as a separate item x str_splitLftRgtTo_midIndxs_to_strL IS OP str strLft strRgt - split str, return [indxs, strLst] +-------------------+ [add, take, replace] [chr, subStr] - return single string : aryList_extractMulplicate_subArys IS OP selectOp strL - find mulplicates in strL by selectOp see d_Qroot 'setup.ndf' - works with strLs, or any array type (in form of list) chr_prepad_str IS OP str len chr - example: zero-prepadding numbers to get constant str length if str_length >= len, returns str, often used for x chr_prepad_str_to_length IS OP str chr length - prepads str with chrs to get length x chr_postpad_str_to_length IS OP str chr length - postpads str with chrs to get length x str_subStrs_takeLenMatches_subStrPairs IS OP str subStrs - return (str = link subStrPairs) x str_takeBetween_StrtEnd IS OP str strStrt strEndr - take between strFront & strEndr (list) x strL_takeOddNum IS OP strL - useful list for [terminal, file] output x subStr_insertBetweenThenLink_strL IS OP subStr strL - link (insert subStr between strL items) x str_repeatNtimesTo_strL IS OP str n - repeats str n times x str_replace_subStr IS OP str subOld subNew - substitutes sub_new for sub_old in str x strL_replace_str IS OP strL subOld subNew - replace all subStrOld by subStrNew in strL x str_replaceAll_strOld IS OP str strOld strNew - strOld is replaced by strNew in str x str_takeBefore_subStr IS OP str subStr - take to the 1st occurence of subStr, else return str ? no good!!! x str_takeAfter_subStr IS OP str subStr - take after the 1st occurence of subStr, else return null? ? no good!!! winID_copyAllTextTo_poutNew IS OP winID pname - copy text of webPage and pre-pend to file see 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' I need an operator for intraPageLinks to TableOfContents (invocable by embedded executable) I need operators for conversions between [QNial, HTML, csv, loaddef] tables +-------------------+ [cut, keep, strip] [chr, subStr, width] - return string lists : x chr_cut_str IS OP str chr - cut a string at each chr, omitting chr, returns a LIST! x chr_cut_strL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! x chrL_cutEACH_strL IS OP chrL strL - cut each strL by each chrL, omitting chrL note that a character list is just a string, but I use "chrL" to emphasize that each chr cuts x subStr_cut_str IS OP subStr str - splits str at each point that subStr occurs, omit subStr x width_cut_str IS OP width str - cut str into strings of equal width, with leftover broken on word boundaries x str_keep_chrL IS OP str chrL - cut a string at each chr, omitting chr, returns a LIST! x strL_keep_chrL IS OP strL chrL - cut each strL by including chrL, omitting non-chrL, x str_stripAllSpacesQ IS OP Str - standard QNial library x str_stripSpacesAll IS OP ERATION Str - removes ALL spaces from a string str_strip_extraWhitespace IS OP Str - removes [leading, multiple-sequence, trailing] whitespace str_endStripChrsOrAddSpaces_to_width IS OP str1 sw - cut string to fixed length, or pad end with spaces to make length x str_strip_chr IS OP chr str - remove chr from string, standard QNial library x str_strip_subStr IS OP str subStr - removes subStr from str +-------------------+ regular expression (regexpr) [fix, check]s : 29Oct2021 optrs below do not handle [apo, unicode]s str_escape_regExprChrL IS OP str regExprChrL - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escapeGrepSearchChrL IS OP str - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escapeSedSearchChrL IS OP str - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s str_escapeSedReplaceChrL IS OP str - do NOT use for pre-composed regexprs!! does not handle [apo, unicode]s strGrepOptions_check IS OP strGrepOptions - check for problematic grep search characters, l if true, fault if not strSedOptions_check IS OP strSedOptions - check for problematic grep search characters, l if true, fault if not str_chrRegExprL_checkNoEscape IS OP str chrRegExprL - check str for non-escaped problematic regexpr chrs the result is either a strL OR a mix of [fault, str]s, with at least one fault does not handle [apo, unicode]s, 05Nov2021 it's not clear that this is even a useful check! strGrepSearchL_checkNoEscape IS OP strGrepSearchL - check str for non-escaped problematic grep search chrs does not handle [apo, unicode]s strSedSearchL_checkNoEscape IS OP strSedSearchL - check strSearch for non-escaped problematic grep chrs does not handle [apo, unicode]s strSedReplaceL_checkNoEscape IS OP strSedReplaceL - check strReplace for non-escaped problematic grep chrs does not handle [apo, unicode]s +-------------------+ convert strings [to, from] other types : atomL_strSep_cartLinkTo_str IS OP S A - creates one string from a list of atoms, separating each by S ary_atomsTo_strs IS OP A - convert atoms of A to strings (leaves strings as strings) x ary_leafsTo_strs IS OP A - every atom is converted to a string, to enable symbolic processing x atomStrA_convertTo_str IS OP A - converts atomStrA to a (single) string list each item separated by one blank (Qnial lib), atoms includes [int, real, complex, phr, boolean] str_convertTo_phrL IS OP Str - returns the list of phrases of the words in the string. numL_convertTo_str IS OP numList - changes a list of reals to a string, each real followed by a space str_convertTo_numOrStr IS OP str - if str can be made numeric [boolean, integer, real] do so otherwise wrap with chr_apo then reduce double to single chr_apos, used by csvTable_readFrm_path strL_eachQuoted_strOut IS OP strL - convert strL to a single string of [quote, space]d subStrs usable in QNial expressions for host commands example : ('bear' 'bull' 'pig' 'wolf') -> '"bear" "bull" "pig" "wolf"' +-------------------+ Unicode [chrs, sub-strings, etc] : many related string optrs are in lists.ndf str_to_unicodeL IS OP str - convert a string to a list of unicode characters (not unicode # sequences) chrL_cutUnicodeIn_str IS OP str chrUnicodeL - cuts str into words by removing chrL (unicode) str_keepUnicode_chrL IS OP str chrL - cuts str into words by keeping chrL (unicode) 18Oct2021 NEEDS FIXING!!!! +-------------------+ Words - are NOT "corrupted" by [search-&-replace, sed, other] replacements (eg QNial operator names) note that the sed -w option does better than my simple coding str_chrL_cutTo_wordL IS OP str chrL - returns the list of words in a string, chrL are wordChrs word_findPosnIn_str IS OP wrd str wType cList - returns a list of positions of a word in a string word_replaceIn_str IS OP sOld sNew str chrL - change word throughout string (safe for variables) +-------------------+ [self-return, file embedded] executables - embedded executables : markup language (eg html) coding in pre-processed text file '[#!: ' is for full-line embeds; '[#=; ' is for embeds within a line a bit like javascript etc, but not "live", just for "compilation" strL_to_strExecuteMirror IS OP strL - convert strL to a self-return executable (eg for writefile) listOfStrL_to_strExecuteMirror IS OP listOfStrL - convert listOfStrL to a self-return executable (eg for writefile) str_executeEmbeds IS OP str phraseValueList - execute embeds in line, return a str '[#!: ' is for full-line embeds; '[#=; ' ' ;=#]' are for embeds within a line +-------------------+ Date-related [timestamps, strings, waits] : now_secondsFrom01Jan1970 IS dateTime_to_UnixSecFrom01Jan1970 IS OP timeStamp sec_from_timestamp IS hhmmss_to_seconds IS OP hhmmss sec_to_hhmmss IS OP secs hhmmss_elapsed IS OP t_start_sec - elapsed time from a given t_start_sec waitSecs IS OP secs - uses Linux sleep, best to simply use host 'sleep 1s' ; wait_hhmmss IS OP secs - Linux sleep, converts hhmmss to ss waitLocal IS OP hhmmss - Linux sleep, converts hhmmss to ss waitVideo IS OP t_voice - used for video production software day_2digit IS OP day - day of month in 2-digit format days_in_month IS OP month - days in monthNumber, (jan = 1, not zero!) daysInYearTo_monthStart IS OP month - days in year up to start of month (not incl 1st day of month) YYMMDD_to_days IS OP YYMMDD - days from (20)000101 to (20)YYMMDD used for calculating days differences when YYMMDD all >= 21st century backTime IS OP YY MM day hur min minLess hurLess dayLess - calculate dateTime using Less values month_name IS OP month_number - given 2-digit month number as text, returns 3 letter month name month_number IS OP month_name - given 3 letter month name , returns month's 2-digit number emlDate_to_YYMMDD IS OP emlDate warning : depends on which unix date format!! eg uses 'Date: Wed, 7 Mar 2018 07:01:01 -0700' emlDate_to_YYMMDD_HHMMSS IS OP emlDate timestamp_YYMMDD IS - returns timestamp in obvious format timestamp_YYMMDD_HM IS - returns timestamp in obvious format timestamp_YYMMDD_HMS IS - returns timestamp in obvious format timestamp_to_YYMMDD_HMS IS OP sys_timestamp - format timestamp eg "dayOfWk MMM DD hh:MM:SS MST YYYY" timestamp_YYYY_MMM_DD_HH_MM_weekDay IS - return current timestamp as strList timestamp_DDMMMYYYY IS - returns timestamp in obvious format timestamp_DDMMMYYYY_HMS IS - returns timestamp in obvious format YYMMDD_to_DDMMMYYYY IS OP YYMMDD - converts dateStr format from fileOrder to manReadable YYMMDD_to_DDMMMYY IS OP YYMMDD - converts dateStr format from fileOrder to manReadable sleep_debug IS OP n_operator fname t_start t_wait - sleeps depending on timestamps +-------------------+ Antique test code : write_testStr IS OP t_name t_input t_standard t_result - means of testing string answers test_comment IS OP t_name t_input t_standard t_result - means of testing string answers write_test_head IS OP t_name t_input t_standard t_result - output header for test? #] fileops - "$d_Qndfs"'z_Archive/211106 07h40m19s file_ops.ndf' #**************************** # List of operators, generated with : # $ grep "^#]" "$d_Qndfs""file_ops.ndf" | sed 's/^#\]/ /' # ********************* loaddefs link d_Qndfs 'file_ops.ndf' +-----+ [pth, dir], [exist, size, dateTimeStamp], [extract, change] names z pth_extract_fname IS OP pth - extract the fileName from a path z pth_extract_dir IS OP pth - extract the directory from a path z pth_extract_dirFname IS OP pth - extract the [dir, fname] from a path z pth_extract_dirBaseExtn IS OP pth - extract [dir, base, extension] from a path-file name z pth_retrieve_subDirFname IS OP pth dirBase - returns (subDir fname) from a path z pth_dateTimeStamp IS OP pth - return the dateTimeStamp of the file z pth_change_extension IS OP pth fileExtension_new - changes fileExtension z pth_delete IS OP pth - delete a file fname_in_fnameGlobalList IS OP fname - test if fname appears in a global list of fnames See 'webSite maintain [menu, header, footer, body] links, TableOfContents.ndf' easy to adapt to other programs? included as a reminder subDir_in_subDirGlobalList IS OP subDir - find the longest valid subSubDir in subDir, within a global-defined root dir See 'webSite maintain [menu, header, footer, body] links, TableOfContents.ndf' easy to adapt to other programs? included as a reminder +-----+ [dir, pth] [test, check, fault]s : pth_typ_exists IS OP pth typer - returns true if a [dir, pth] exists, or can be created pth_typ_checkExists IS OP pth typ - check if pth is a legitimate path of type typ z pth_size IS OP pth - returns [dir, pth]size in [T,G,M,K]-byte format, diSize is recursive total z pth_isEmpty IS OP pth - returns l if true and o if false, applicable to [dir, pth]s Warning : if a path does not exist, then as per Linux convention, this returns o (non-existent files aren't empty!) I had bandone pthL_faultLL_shortenTo_Codes IS OP pthL faultLL - for _tests, maybe general use [pthL, faultL] for faults are converted to codes for brevity in the output of course, a resultCode of null (true) is kept the same z checkWrite_pth_pthTyp IS OP pnew pthTyp - check validity of proposed writefile +-----+ [backup, restore] cart [pth, dir]s z pth_backupDatedTo_zArchive IS OP pth - SAFE WORKING backup file to a z_Archive dated today (create?) zArchive is [specific, with respect] to each path, it is not an overall zArchive Notice that there is no error output (write) - that must be handeled by the calling optr! z pth_find_latestZarchive IS OP pth - look for the most recent version of fname in d_zArchive z pZarchive_restore IS OP pth - restore most recent pth_backupDatedTo_zArchive of a file, retain the backup z pthL_backupTo_dirFlat IS OP pthL d_backup - backup multi-dir paths to a (created) FLAT dir This is often used for d_webRawe work, placed into a dated directory for a [pthL, dir] operation There will be a problem with fnames that are the same!!! Notice that there is no error output (write) - that must be handeled by the calling optr! dirFlat_restoreTo_pthL IS OP flag_fnamesDated d_backup pthL - restore dated paths from a FLAT d_backup, created with pthL_backupTo_dirFlat +-----+ [find, count] [chr, str, word]s in d_Qndfs [file,dir]s - including [find,grep] simple command line stuff d_Qndfs [bash script, QNial [optr,var,etc]]s - [pth, lineNum]s (Linux commands) for now I just have [find,grep] simple command line stuff z pth_chr_write_strLChrUnbalanced IS OP pth - write lines of path with unbalanced apos +-----+ z str_in_path IS OP Substr p_name p_hostCmdRslt - boolean indicator that Substr is in file p_name just uses Unix grep in host mode!! z pth_lineNumOf_chrSet IS OP pth chrSet - find [in, NOT in] characters in path z pthL_findCountsEach_strL IS OP pthL strL pout flag_word - count each of [word, str]L hits in each path listed in a file uses grep therefore may not simply handle grep restricted : search $.*/[\]^ List Howells [bash script, QNial optr]s - essential map for finding shit, twig the bash cmd line see "$d_bin""0_list Howells [bash scripts, QNial operators].sh" $ find "$d_Qndfs" -name "*.ndf" |...[greps,sort]...| xargs...grep "#\] " "FILE" | sed List usage of one of Howells QNial [optr,var,etc]s - bash command line, substitute for actually good for any text in .ndf files $ find "$d_Qndfs" -name "*.ndf" |...[greps,sort]...| xargs -0 -IFILE grep..."" "FILE" +-----+ replace [chr, word, str] in [file, directory] z pthL_replace_wordL IS OP pthL wordOldNewL flag_word flag_backup - change [str, word]L each pthL uses sed, therefore cannot simply handle sed restricted : search $.*/[\]^ replace &\/\n backups to z_Archive under dir of file being backed up. Auto-created if doesn't exist z pthL_replace_strL IS OP pthL strOldNewL flag_backup - change strL each pthL uses sed, therefore cannot simply handle sed restricted : search $.*/[\]^ replace &\/\n defaults to pth_backupDatedTo_zArchive z pth_replace_strOldNewL IS OP pth strOldNewL flag_backup - res ipsa loquitor DANGEROUS! safer if one can use words, eg pth_replace_word, need to upgrade to multi-sed defaults to pth_backupDatedTo_zArchive z pth_replace_str IS OP pth strOld strNew flag_backup - res ipsa loquitor defaults to pth_backupDatedTo_zArchive z pinn_removeWhiteLines_pout - use grep (example overwrites original path) : eg host link 'grep "\S" "' p_temp1 '" >"' p_temp2 '" && mv "' p_temp1 '" "' p_temp1 '"' ; z pth_removeLeadWhiteLines IS OP p_emlOne p_emlOne_noEmptyLines - required to use emails as attachments z pth_replace_lineOldNewL IS OP pth lineOldNewL - [p_inn lineOldL] to [p_out, lineNewL] AVOIDs sed, therefore NOT affected by sed restricted : search $.*/[\]^ replace &\/\n default backup by pth_backupDatedTo_zArchive, overwrites original path dir_pExtn_replace_wordL IS OP dir pExtn wordOldNewL flag_backup - change wordL in dir pExtn allows files of a specific exten to be targeted z dir_pExtn_replace_str IS OP dir pExtn strOld strNew flag_backup - change strOld to strNew in dir, uses regexp pExtn to generate pthL +-----+ [read, write] cart [str, ary, listOfStr, listOfStrPair, UnixCmd][,L] z pth_read_strL IS OP pth - simple read of file as a list (1D array) of strings, one per line z pth_readExecuteLines_aryL IS OP pth - make a list of the results of executing each line of pinn "apo-enclose" strings unless they are [variable, operator, transformer, etc] on each line z strL_writeOvr_pout IS OP strL pout - write a list of strings to a path line of fout (not a path!) strL_write_fout IS OP strL fout - write a list of strs, apo-enclosed separated by spaces, as one output line to fout (not a path!), WARNING: assumes length(strL) < max strLength for fileInput listOfStrL_write_fout IS OP listOfStrL fout - write a list of strPairs, as one output line to fout (not a path!), WARNING: assumes length(strL) < max strLength for fileInput z str_appendTo_pthOrHandle IS OP str pthOrHandle - res ipsa loquitor stdout - there is no overwrite, as stdout is automatically append. a dummy 1 is put in for argList 25Oct2021 other filehandles - don't know yet, will try when I need it z str_overWriteTo_pthOrHandle IS OP str pthOrHandle - res ipsa loquitor a dummy 1 is put into code to satisfy argList 25Oct2021 other filehandles - don't know yet, will try when I need it +-----+ [sort, catenate] file z pinn_sortupTo_pout IS OP p_inn p_out z pinn_sortCatTo_pout IS OP pinnList pout - sort each file in pinnList, concatenate to pout +-----+ file sections [add, remove, whatever] z pinn_cutHeadTail_pout IS OP headLine tailLine pinn pout - res ipsa loquitor - uses key lines z pinn_yahooNewsItemsExtract_pout IS OP pinn pout - res ipsa loquitor see link d_Qndfs 'economics, markets/winURL yahoo finance news download.ndf' +-----+ file handles and embedded executables - eg to insert [menu, header, footer]s into html files : Although built for webSite maintenance, with adaptation these may have far more general applicability. see 'Website updates.ndf' for : internalLinks_return_backupSubDirFnames - for an an internal link, where SubDir goes into d_webSite internalLinks_return_relativepth - also using executeEmbeds when present str_executeEmbeds - execute embeds in line as an example : webPage_update - update pinn to d_out using executeEmbeds z pth_insertIn_fHand IS OP p_insert fHand - insert p_insert into fHand at the current writefile point pWebWorkL_change_headFoot IS OP pthL - change all whole-line-embeds for pthL this is currently d_webRaw specific, used to build Howell's webSite [menu, header, footer, etc]s executeEmbedsGet_pthTemp IS - generate a unique p_temp fname z pth_executeEmbeds IS OP pth phraseValueList - execute embeds in path, [output to, return] p_temp '[#!: ' is for full-line embeds; '[#=; ' ' ;=#]' are for embeds within a line z pth_executeEmbedsInsertIn_fHand IS OP pth phraseValueList - execute embeds, insert in fileHandle +-----+ URL [down, up]-load z url_downloadTo_pth IS OP URLname pth - command line download z url_downloadTxtTo_pth IS OP URLname winTitle winIDTxtEditor - download text only (no [html, css] code) +-----+ [read, write] special [table, Unix cmdResult] formats z csvTable_readFrom_pth IS OP pth - read a csv table from file, cells to [apo-str, numeric] table_writeCSVformatTo_pth IS OP table pth - writefile table to path, [tab-separated cols, apo-text] important - assumes 2D table of ONLY [string, atomic data] types (eg not lists of numbers...) z tabTable_readFrm_pth IS OP pth - read file as a table with tab delineated cols (eg spreadsheet) z tabTable_writeTo_pth IS OP tabTable pth - write table to file, tab delineated z wcUnix_readFrom_pth IS OP pth - read file as a table with tab delineated cols (eg txt from spreadsheet) line count of file : tonumber first (host_result link 'wc -l "' '" | sed '' z winID_copyAllTextTo_poutNew IS OP winID pname - copy text of webPage and pre-pend to file see 'windows [open, close, ID, title], [get,set,move] cart [posn,size].ndf' 20Oct2021 I have lost this!!??!! +-----+ z pth_addISOPdebug[, _marked] - add debug lines prior to optr descriptions to track loaddefs of path z pth_addISOPdebug IS OP pth - add ['IF debug', '#] '] to optr descriptions to help debugging via loaddefs this is for ndf files whose optrs do NOT have a menu TableOfContents marker (line starts with '#] ') z pth_addISOPdebug_marked IS OP pth - add only 'IF debug' to optr descriptions already having '#] ' +-----+ [debug, log] file optrs - 21Oct2021 not used much any more... write_debug IS OP AAA - writes debug information to the screen writefile_debug IS OP AAA - killfile_debug IS - writefile_log IS OP AAA - logs picture of array to d_QNial_temp '0_QNial log.txt' killfile_log IS - erases logfile d_QNial_temp '0_QNial log.txt' # enddoc