CS timeline


Una segnalazione, forse incompleta o forse non ancora completa che –colpa mia– avevo messo in un memo poi dimenticato. Ma ritrovato cercando altro (che sono sicuro c’è ma non riesco a trovare).
Uno dei miei interessi è l’aspetto storico dell’informatica, non solo nelle sue ultime manifestazioni. Anzi non ho nemmeno più il telefono: non sono mobile😳

Il prof Scott Aaronson compila l’elenco dei fatti fondamentali riguardanti la Computer Science. Per adesso ho questi due link:

Poi attraverso i commenti è possibile –non devo certo ricordare queste cose, vero? Enjoy😀

Il blog di Scott (bello il nome anche se richiede una googlata) purtroppo non lo seguo come meriterebbe ma spero di riuscire a intercettare eventuali sviluppi (m’interessano) e aggiornare questo post.

cit. & LOLL – 2

Fa caldo —forse l’ho già detto— ma ecco…


My new obsession: look at webpage sources for every site I visit, trying to guess the CMS they use
::: marcodelmastro

Ooooops! #PokemonGO
::: Lovelovingvio

Running your Perl or shell script for the first time
::: Google+

The Evolution of Language
::: Philip Wadler

I know I am not the only one. You think the same, don’t you?
::: itsfoss


In case you forgot one of the most important laws of the universe, there’s this
::: jessysaurusrex

Apparently everyone in my feed is watching something else
::: lizardbill

yeah… don’t worry about the robot apocalypse
::: internetofshit

Infinite recursion
::: ThePracticalDev

git merge
::: ThePracticalDev

I will build a great std::barrier to keep JavaScript programmers out
‘mericana ma lollosissimissima
::: isotrumpp


Io così
::: ilpipotto

#ChuckNorris ha catturato tutti i 720 #Pokemon
::: Chucckk_Norris

The Problem with Programming
::: kOoLiNuS

After watching so many senior Democrats demonize encryption technology
::: csoghoian

Devhumor – humor for developers
appena coperto (& ‘niziato a copiare)
::: Devhumor


Octave – data containers – creare structures – 27


Sempre sulle structures, proseguendo da qui copio qui.

Creare structures
Besides the index operator “.“, Octave can use dynamic naming “(var)” or the struct function to create structures. Dynamic naming uses the string value of a variable as the field name. For example:


Dynamic indexing also allows you to use arbitrary strings, not merely valid Octave identifiers (note that this does not work on MATLAB):


The warning id Octave:language-extension can be enabled to warn about this usage. See warning_ids.
Perso: mah… serve? o fa solo confusione?😦

More realistically, all of the functions that operate on strings can be used to build the correct field name before it is entered into the data structure.


The third way to create structures is the struct command. struct takes pairs of arguments, where the first argument in the pair is the fieldname to include in the structure and the second is a scalar or cell array, representing the values to include in the structure or structure array. For example:


Built-in Function: s = struct ()
Built-in Function: s = struct (field1, value1, field2, value2, ...)
Built-in Function: s = struct (obj)

Create a scalar or array structure and initialize its values.
The field1, field2, … variables are strings specifying the names of the fields and the value1, value2, … variables can be of any type.
If the values are cell arrays, create a structure array and initialize its values. The dimensions of each cell array of values must match. Singleton cells and non-cell values are repeated so that they fill the entire array. If the cells are empty, create an empty structure array with the specified field names.
If the argument is an object, return the underlying struct.

Observe that the syntax is optimized for struct arrays. Consider the following examples:


he first case is an ordinary scalar struct—one field, one value. The second produces an empty struct array with one field and no values, since being passed an empty cell array of struct array values. When the value is a cell array containing a single entry, this becomes a scalar struct with that single entry as the value of the field. That single entry happens to be an empty cell array.
Finally, if the value is a non-scalar cell array, then struct produces a struct array.

The function isstruct can be used to test if an object is a structure or a structure array.

Built-in Function: isstruct (x)
Return true if x is a structure or a structure array.



Octave – data containers – 26


Sempre sulle structures, qui, proseguendo da qui.
Structure Arrays
A structure array is a particular instance of a structure, where each of the fields of the structure is represented by a cell array. Each of these cell arrays has the same dimensions. Conceptually, a structure array can also be seen as an array of structures with identical fields. An example of the creation of a structure array is


which creates a 2-by-1 structure array with two fields. Another way to create a structure array is with the struct function (see Creating Structures). As previously, to print the value of the structure array, you can type its name:


Individual elements of the structure array can be returned by indexing the variable like x(1), which returns a structure with two fields:


Furthermore, the structure array can return a comma separated list of field values (see Comma Separated Lists), if indexed by one of its own field names. For example:


Here is another example, using this comma separated list on the left-hand side of an assignment:


Just as for numerical arrays, it is possible to use vectors as indices (see Index Expressions):


The function size will return the size of the structure. For the example above


Elements can be deleted from a structure array in a similar manner to a numerical array, by assigning the elements to an empty matrix. For example



Octave – data containers – 25


Finite le stringhe, qui, oggi argomento nuovo, copio qui.

Data containers

Octave includes support for two different mechanisms to contain arbitrary data types in the same variable. Structures, which are C-like, and are indexed with named fields, and cell arrays, where each element of the array can have a different data type and or shape. Multiple input arguments and return values of functions are organized as another data container, the comma separated list.

OK, pronto per le structures, qui

Octave includes support for organizing data in structures. The current implementation uses an associative array with indices limited to strings, but the syntax is more like C-style structures.

Ahemmm… solo una lista di altre pagine, passo qui.

Here are some examples of using data structures in Octave.
Elements of structures can be of any value type. For example, the three expressions


The ‘.’ character separates the structure name from the field name and indicates to Octave that this variable is a structure.

Note that Octave may print the elements in any order.

Structures may be copied just like any other variable:


Since structures are themselves values, structure elements may reference other structures. The following statements change the value of the element b of the structure x to be a data structure containing the single element d, which has a value of 3.


L’esempio proposto mi da errore, ho modificato il codice ottenendo infine il risultato voluto.

Note that when Octave prints the value of a structure that contains other structures, only a few levels are displayed. For example:


This prevents long and confusing output from large deeply nested structures. The number of levels to print for nested structures may be set with the function struct_levels_to_print, and the function print_struct_array_contents may be used to enable printing of the contents of structure arrays.

Built-in Function: val = struct_levels_to_print ()
Built-in Function: old_val = struct_levels_to_print (new_val)
Built-in Function: struct_levels_to_print (new_val, "local")

Query or set the internal variable that specifies the number of structure levels to display.
When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

Built-in Function: val = print_struct_array_contents ()
Built-in Function: old_val = print_struct_array_contents (new_val)
Built-in Function: print_struct_array_contents (new_val, "local")

Query or set the internal variable that specifies whether to print struct array contents.
If true, values of struct array elements are printed. This variable does not affect scalar structures whose elements are always printed. In both cases, however, printing will be limited to the number of levels specified by struct_levels_to_print.
When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

Functions can return structures. For example, the following function separates the real and complex parts of a matrix and stores them in two elements of the same structure variable.


When called with a complex-valued argument, f returns the data structure containing the real and imaginary parts of the original function argument.


Function return lists can include structure elements, and they may be indexed like any other variable. For example: no mi da errore😦
Dovrebbe essere

[ x.u, x.s(2:3,2:3), x.v ] = svd ([1, 2; 3, 4]);
     ⇒ x =
          u =

            -0.40455  -0.91451
            -0.91451   0.40455

          s =

             0.00000   0.00000   0.00000
             0.00000   5.46499   0.00000
             0.00000   0.00000   0.36597

          v =

            -0.57605   0.81742
            -0.81742  -0.57605


It is also possible to cycle through all the elements of a structure in a loop, using a special form of the for statement (see Looping Over Structure Elements).


Visto nel Web – 245

Attività ridotta mia e ontehtoobz; cmq ecco cosa ho visto nel Web.


Inter-Procedural Optimization and Derefinement
#:linguaggi di programmazione
::: Playing With Pointers

is a novel language for distributed and concurrent programming
#:linguaggi di programmazione
::: Orc Language Project

“E’ iniziato il cambiamento.” Anche l’#Atac assume personale affetto da disturbo paranoide della personalità?
#:social media
::: _odisseus

Glumpy is a python library for scientific visualization that is both fast, scalable and beautiful.
#:programming, codice, snippet
::: Glumpy

Email o social media?
io sono per l’Email
#:Web, Internet
::: Sergio Gridelli


Del malcostume di copiare gli articoli senza citare la fonte
#:Web, Internet
::: Dario Cavedon

Interviewing my mother, a mainframe COBOL programmer
::: Medium

A new atomic hard drive could store all of Earth’s books on a postage stamp
#:innovazioni, futuro
::: SAI

#digitalhumanities tutorials – definitely on my ‘to do’ list this summer
::: Tor_Barker

WikiLeaks Releases 300K Turkey Government Emails In Response To Erdogan’s Post-Coup Purges
#:Web, Internet
::: Slashdot


Free Programming Books for Coders of All Levels
#:programming, codice, snippet
::: I am Programmer

Come richiedere un account verificato Twitter
non m’interessa ma chissà…
#:social media
::: Chimera Revo

Microsoft blocca l’installazione di altri OS su dispositivi Windows RT
#:sistemi operativi
::: lffl

Pokémon GO e la direzione del futuro
::: Sergio Gridelli

If you want to bootstrap a Lisp->Javascript compiler
#:lisp e derivati
::: davazp


pifpaf 0.10.0
Suite of tools and fixtures to manage daemons for testing
#:tools, componenti software
::: PyPI

#CurryOn Rome videos already rolling in on our YouTube channel
#:linguaggi di programmazione
::: curry_on_conf

Git Magic ebook
#:manuali, how to
::: Stanford CS

view the generated HTML source in Firefox
#:Web, Internet
::: The Ubuntu Incident

AT&T Hopes Open Source SDN Platform Will Become ‘Industry Standard’
#:free open source software
::: Virtualization Review


Gow – The lightweight alternative to Cygwin
Gow (Gnu On Windows) is the lightweight alternative to Cygwin
#:tools, componenti software
::: bmatzelle

Apple To Make $3 Billion From Pokemon Go
::: Slashdot

Stack Overflow goes beyond Q&As and launches crowdsourced documentation
::: TechCrunch

An Introduction to Recursion Schemes
#:programmazione funzionale
::: Adventures in Uncertainty ::: Adventures in Uncertainty ::: Adventures in Uncertainty

Using Golang For Custom Wallpapers
io avevo fatto una cosa simile con Python, anni fa
::: John Pettigrew

Practical Guide to Bare Metal C++
#:manuali, how to
::: Alex Robenko


LLVM Programmer’s Manual
#:manuali, how to
::: LLVM

excited to announce Amazon artificial intelligence & machine learning center in Turin
::: JeffBezos ::: Business Insider

Racket v6.6 is out!
#:lisp e derivati
::: racketlang

Wrote and edited some documentation for Common #Lisp on Stackoverflow
#:lisp e derivati
::: RainerJoswig

A Formal Verification of Rust’s Binary Search Implementation
una cosa teorica, ostica, ottima😀
#:programming, codice, snippet
::: The Axiom of False

13th Intern. Congress on Mathematical Education in Hamburg. ‘USING #LISP AS A TOOL FOR MATHEMATICAL EXPERIMENTATION’
#:lisp e derivati
::: RainerJoswig


Coconut – operatori II


Ci sono argomenti istituzionali come Octave (sì siamo in ritardo ma il caldo, le ferie, …) e ci sono argomenti che forse poi –chissà– come Coconut. Poi ce ne sono anche altri ancora, come SICP, che meriterebbero più attenzione. Avendo tempo. OK, oggi Coconut, continuo da qui a copiare qui.

Iterator Slicing
Coconut uses a $ sign right after an iterator before a slice to perform iterator slicing. Coconut’s iterator slicing works much the same as Python’s sequence slicing, and looks much the same as Coconut’s partial application, but with brackets instead of parentheses. It has the same precedence as subscription.
Iterator slicing works just like sequence slicing, including support for negative indices and slices, and support for slice objects in the same way as can be done with normal slicing. Iterator slicing makes no guarantee, however, that the original iterator passed to it be preserved (to preserve the iterator, use Coconut’s tee function).
Coconut’s iterator slicing is very similar to Python’s itertools.islice, but unlike itertools.islice, Coconut’s iterator slicing supports negative indices, and is optimized to play nicely with custom or built-in sequence types as well as Coconut’s map, zip, range, and count objects, only computing the elements of each that are actually necessary to extract the desired slice. This behavior can also be extended to custom objects if they define their __getitem__ method lazily and set __coconut_is_lazy__ to True.


Nota: il manuale usa 10**100 ma mi da overflow😳

With Python can’t be done without a complicated iterator slicing function and inspection of custom objects. The necessary definitions in Python can be found in the Coconut header.

Alternative Unicode
Coconut supports Unicode alternatives to many different operator symbols. The Unicode alternatives are relatively straightforward, and chosen to reflect the look and/or meaning of the original symbol.

→ (\u2192)                  => "->"
↦ (\u21a6)                  => "|>"
*↦ (*\u21a6)                => "|*>"
↤ (\u21a4)                  => "<|" 
↤* (\u21a4*)                => "<*|" 
⋅ (\u22c5)                  => "*"
↑ (\u2191)                  => "**"
÷ (\xf7)                    => "/"
÷/ (\xf7/)                  => "//"
∘ (\u2218)                  => ".."
− (\u2212)                  => "-" (only subtraction)
⁻ (\u207b)                  => "-" (only negation)
¬ (\xac)                    => "~"
≠ (\u2260) or ¬= (\xac=)    => "!="
≤ (\u2264)                  => "<=" 
≥ (\u2265)                  => ">="
∧ (\u2227) or ∩ (\u2229)    => "&"
∨ (\u2228) or ∪ (\u222a)    => "|"
⊻ (\u22bb) or ⊕ (\u2295)    => "^"
« (\xab)                    => "<<" 
» (\xbb)                    => ">>"
… (\u2026)                  => "..."
× (\xd7)                    => "@" (only matrix multiplication)


OK, ma forse –sono vecchio– perché cambiare. E poi non è comodissimo introdurre il codice dopo C-S-u. Non sono riuscito a usare quelli con il codice esadecimale, per esempio xf7.


The syntax for data blocks is a cross between the syntax for functions and the syntax for classes. The first line looks like a function definition, but the rest of the body looks like a class, usually containing method definitions. This is because while data blocks actually end up as classes in Python, Coconut automatically creates a special, immutable constructor based on the given arguments.

Coconut data blocks create immutable classes derived from collections.namedtuple and made immutable with __slots__. Coconut data statement syntax looks like:

data <name>(<args>):

<name> is the name of the new data type, <args> are the arguments to its constructor as well as the names of its attributes, and <body> contains the data type’s methods.Subclassing data types can be done easily by inheriting from them in a normal Python class, although to make the new subclass immutable, the line

__slots__ = ()

A mainstay of functional programming that Coconut improves in Python is the use of values, or immutable data types. Immutable data can be very useful because it guarantees that once you have some data it won’t change, but in Python creating custom immutable data types is difficult. Coconut makes it very easy by providing data blocks.

Python Docs
Returns a new tuple subclass. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable. Instances of the subclass also have a helpful docstring (with type names and field names) and a helpful __repr__() method which lists the tuple contents in a name=value format.

Any valid Python identifier may be used for a field name except for names starting with an underscore. Valid identifiers consist of letters, digits, and underscores but do not start with a digit or underscore and cannot be a keyword such as class, for, return, global, pass, or raise.

Named tuple instances do not have per-instance dictionaries, so they are lightweight and require no more memory than regular tuples.


This will fail because data objects are immutable


la versione Python


Showcases the syntax, features, and immutable nature of data types.


Nota: la riga dopo il decoratore viene scritta in modo bizzarro nella REPL, quella corretta è def size(Node(left, right)) = size(left) + size(right) ovviamente.

la versione Python


Pausa, devo digerire il tutto; poi continuo sempre sulle keywords😀

Octave – stringhe – VIII – 24


Sempre stringhe, da qui copiando qui.

Funzioni per la classe character
Octave also provides the following character class test functions patterned after the functions in the standard C library. They all operate on string arrays and return matrices of zeros and ones. Elements that are nonzero indicate that the condition was true for the corresponding character in the string array. For example:


Mapping Function: isalnum (s)
Return a logical array which is true where the elements of s are letters or digits and false where they are not.
This is equivalent to (isalpha (s) | isdigit (s)).

Mapping Function: isalpha (s)
Return a logical array which is true where the elements of s are letters and false where they are not.
This is equivalent to (islower (s) | isupper (s)).

Function File: isletter (s)
Is an alias for the isalpha function.

Mapping Function: islower (s)
Return a logical array which is true where the elements of s are lowercase letters and false where they are not.


Mapping Function: isupper (s)
Return a logical array which is true where the elements of s are uppercase letters and false where they are not.

Mapping Function: isdigit (s)
Return a logical array which is true where the elements of s are decimal digits (0-9) and false where they are not.

Mapping Function: isxdigit (s)
Return a logical array which is true where the elements of s are hexadecimal digits (0-9 and a-fA-F).


Mapping Function: ispunct (s)
Return a logical array which is true where the elements of s are punctuation characters and false where they are not.


Mapping Function: isspace (s)
Return a logical array which is true where the elements of s are whitespace characters (space, formfeed, newline, carriage return, tab, and vertical tab) and false where they are not.

Mapping Function: iscntrl (s)
Return a logical array which is true where the elements of s are control characters and false where they are not.


Mapping Function: isgraph (s)
Mapping Function: isprint (s)

Return a logical array which is true where the elements of s are printable characters (but not the space character) and false where they are not.


Mapping Function: isascii (s)
Return a logical array which is true where the elements of s are ASCII characters (in the range 0 to 127 decimal) and false where they are not.


Attenzione che non è come sembra: il controllo viene fatto sui bytes:


Function File: isstrprop (str, prop)
Test character string properties.
If str is a cell array, isstrpop is applied recursively to each element of the cell array.
Numeric arrays are converted to character strings.

The second argument prop must be one of

  • "alpha" True for characters that are alphabetic (letters).
  • "alnum" "alphanum" True for characters that are alphabetic or digits.
  • "lower" True for lowercase letters.
  • "upper" True for uppercase letters.
  • "digit" True for decimal digits (0-9).
  • "xdigit" True for hexadecimal digits (a-fA-F0-9).
  • "space" "wspace" True for whitespace characters (space, formfeed, newline, carriage return, tab, vertical tab).
  • "punct" True for punctuation characters (printing characters except space or letter or digit).
  • "cntrl" True for control characters.
  • "graph" "graphic" True for printing characters except space.
  • "print" True for printing characters including space.
  • "ascii" True for characters that are in the range of ASCII encoding.


Cioè, se ho capito bene isstrprop fa tutto quello che fanno tutte le altre, in base a prop.

Dai, prossimamente si cambia😀


cit. & LOLL – 1

Pare funzioni la raccolta delle cose meno seriose viste in settimana; vediamo se le prove devono continuare. E poi oggi c’è da ricordare un avvenimento speciale😀


the reason python is the best numerical language
::: moorepants

pare che piace
::: f_126_ck

it’s really very hard to identify the funnest part of this document
::: johnregehr

OH: “What’s systemd?”
::: QEDunham

Come to the nerd side…
::: SciencePorn


Equally true of #programming #imho
::: Symbo1ics

Durante il #GolpeTurchia #Erdogan per salvarsi usa i social network
::: SteBiotech

Looks like my colleague and I have gained a reputation
::: sanityinc

::: SciencePorn

A Phylogeny and Evolutionary History of the Pokémon
::: Improbable Research


Pratchett moment at @curry_on_conf
::: alcortesm1

how to be a wizard programmer
::: b0rk

IT HAS BEGUN #curryon
sì, vale il tutto-maiuscolo
::: bodil ::: bodil

Git Merge
::: manisha72617183

5K people turn up to catch Pokémon in Chicago
::: TechCrunch


Larry Wall is wearing a shirt that says “Need New Haters
::: cmeik

Nell’informatica si capisce subito quando ti propongono un lavoro di merda
::: PTKDev

There are 10 types of people
::: pyjokes_bot

::: DynamicWebPaige

I think I found a bug in ENIAC…
::: PyBeeWare


Octave – stringhe – VII – 23


Sempre stringhe, continuo da qui e oggi affronto un argomento speciale, le regexps, copiando qui.

Built-in Function: [s, e, te, m, t, nm, sp] = regexp (str, pat)
Built-in Function: [...] = regexp (str, pat, "opt1", ...)

Regular expression string matching.
Search for pat in str and return the positions and substrings of any matches, or empty values if there are none.

The matched pattern pat can include any of the standard regex operators, including:

  • . Match any character
  • * + ? {} Repetition operators, representing
  • * Match zero or more times
  • + Match one or more times
  • ? Match zero or one times
  • {n} Match exactly n times
  • {n,} Match n or more times
  • {m,n} Match between m and n times
  • [...] [^...] List operators. The pattern will match any character listed between “[” and “]“. If the first character is “^” then the pattern is inverted and any character except those listed between brackets will match.
    Escape sequences defined below can also be used inside list operators. For example, a template for a floating point number might be [-+.\d]+.
  • () (?:) Grouping operator. The first form, parentheses only, also creates a token.
  • | Alternation operator. Match one of a choice of regular expressions. The alternatives must be delimited by the grouping operator () above.
  • ^ $ Anchoring operators. Requires pattern to occur at the start (^) or end ($) of the string.

In addition, the following escaped characters have special meaning.

  • \d Match any digit
  • \D Match any non-digit
  • \s Match any whitespace character
  • \S Match any non-whitespace character
  • \w Match any word character
  • \W Match any non-word character
  • \< Match the beginning of a word
  • \> Match the end of a word
  • \B Match within a word

Implementation Note: For compatibility with MATLAB, escape sequences in pat (e.g., “\n” => newline) are expanded even when pat has been defined with single quotes. To disable expansion use a second backslash before the escape sequence (e.g., “\\n“) or use the regexptranslate function.

The outputs of regexp default to the order given below

  • s The start indices of each matching substring
  • e The end indices of each matching substring
  • te The extents of each matched token surrounded by (...) in pat
  • m A cell array of the text of each match
  • t A cell array of the text of each token matched
  • nm A structure containing the text of each matched named token, with the name being used as the fieldname. A named token is denoted by (?<name>...).
  • sp A cell array of the text not returned by match, i.e., what remains if you split the string based on pat.

Particular output arguments, or the order of the output arguments, can be selected by additional opt arguments. These are strings and the correspondence between the output arguments and the optional argument are

'start'            s
'end'              e
'tokenExtents'     te
'match'            m
'tokens'           t
'names'            nm
'split'            sp

Additional arguments are summarized below.

  • ‘once’ Return only the first occurrence of the pattern.
  • ‘matchcase’ Make the matching case sensitive. (default)
    Alternatively, use (?-i) in the pattern.
  • ‘ignorecase’ Ignore case when matching the pattern to the string.
    Alternatively, use (?i) in the pattern.
  • ‘stringanchors’ Match the anchor characters at the beginning and end of the string. (default)
    Alternatively, use (?-m) in the pattern.
  • ‘lineanchors’ Match the anchor characters at the beginning and end of the line.
    Alternatively, use (?m) in the pattern.
  • ‘dotall’ The pattern . matches all characters including the newline character. (default)
    Alternatively, use (?s) in the pattern.
  • ‘dotexceptnewline’ The pattern . matches all characters except the newline character.
    Alternatively, use (?-s) in the pattern.
  • ‘literalspacing’ All characters in the pattern, including whitespace, are significant and are used in pattern matching. (default)
    Alternatively, use (?-x) in the pattern.
  • ‘freespacing’ The pattern may include arbitrary whitespace and also comments beginning with the character ‘#’.
    Alternatively, use (?x) in the pattern.
  • ‘noemptymatch’ Zero-length matches are not returned. (default)
  • ‘emptymatch’ Return zero-length matches.
    regexp ('a', 'b*', 'emptymatch') returns [1 2] because there are zero or more ‘b‘ characters at positions 1 and end-of-string.

Built-in Function: [s, e, te, m, t, nm, sp] = regexpi (str, pat)
Built-in Function: [...] = regexpi (str, pat, "opt1", ...)

Case insensitive regular expression string matching.
Search for pat in str and return the positions and substrings of any matches, or empty values if there are none. See regexp, for details on the syntax of the search pattern.

Built-in Function: outstr = regexprep (string, pat, repstr)
Built-in Function: outstr = regexprep (string, pat, repstr, "opt1", ...)

Replace occurrences of pattern pat in string with repstr.
The pattern is a regular expression as documented for regexp.


Options in addition to those of regexp are

  • ‘once’ Replace only the first occurrence of pat in the result.
  • ‘warnings’ This option is present for compatibility but is ignored.

Implementation Note: For compatibility with MATLAB, escape sequences in pat (e.g., “\n” => newline) are expanded even when pat has been defined with single quotes. To disable expansion use a second backslash before the escape sequence (e.g., “\\n“) or use the regexptranslate function.

Function File: regexptranslate (op, s)
Translate a string for use in a regular expression.
This may include either wildcard replacement or special character escaping.
The behavior is controlled by op which can take the following values

  • "wildcard" The wildcard characters ., *, and ? are replaced with wildcards that are appropriate for a regular expression.
  • "escape" The characters $.?[], that have special meaning for regular expressions are escaped so that they are treated literally.


Function File: untabify (t)
Function File: untabify (t, tw)
Function File: untabify (t, tw, deblank)

Replace TAB characters in t with spaces.
The input, t, may be either a 2-D character array, or a cell array of character strings. The output is the same class as the input.
The tab width is specified by tw, and defaults to eight.
If the optional argument deblank is true, then the spaces will be removed from the end of the character data.

The following example reads a file and writes an untabified version of the same file with trailing spaces stripped.
Uso un file ottenuto copiando una parte di un file di sistema (di Octave), questo:

function [varargout] = getfields (s, varargin)

	if (! all (isfield (s, varargin)))
		error ("getfields: some fields not present");

	if (all (size (s) <= 1))
		varargout = fields2cell (s, varargin);
		error ("getfields: structure must be scalar or empty");



Adesso come faccio a far vedere che ha funzionato e i tab (8 char) sono stati sostituiti da spazi? Uh! c’è diff:


Le regexps sono abbastanza simili alle solite per cui niente screenshots inutili. E –al solito– quando si dovessero usare si dovranno fare tentativi, senza perdere la pazienza, senza scoraggiarsi😉



Ricevi al tuo indirizzo email tutti i nuovi post del sito.

Segui assieme ad altri 95 follower