Maxima – 28 – Tipi di dati e strutture – arrays – 2

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.88.

arraymake( A, [i_1, ..., i_n])
Returns the expression A[i_1, ..., i_n]. The result is an unevaluated array reference.

arraymake is reminiscent of funmake, except the return value is an unevaluated array reference instead of an unevaluated function call.

(%i1) arraymake(A, [1]);
(%o1)                                 A
                                       1
(%i2) arraymake(A, [k]);
(%o2)                                 A
                                       k
(%i3) arraymake(A, [i, j, 3]);
(%o3)                              A
                                    i, j, 3
(%i4) array(A, fixnum, 10);
(%o4)                                  A
(%i5) fillarray(A, makelist (i^2, i, 1, 11));
(%o5)                                  A
(%i6) arraymake(A, [5]);
(%o6)                                 A
                                       5
(%i7) ''%;
(%o7)                                 36
(%i8) L : [a, b, c, d, e];
(%o8)                           [a, b, c, d, e]
(%i9) arraymake('L, [n]);
(%o9)                                 L
                                       n
(%i10) ''%, n = 3;
(%o10)                                 c
(%i11) A2 : make_array(fixnum, 10);
(%o11)               {Lisp Array: #(0 0 0 0 0 0 0 0 0 0)}
(%i12) fillarray(A2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o12)               {Lisp Array: #(1 2 3 4 5 6 7 8 9 10)}
(%i13) arraymake('A2, [8]);
(%o13)                                A2
                                        8
(%i14) ''%;
(%o14)                                 9

arrays
Default value: []

arrays is a list of arrays that have been allocated. These comprise arrays declared by array, hashed arrays constructed by implicit definition (assigning something to an array element), and array functions defined by := and define. Arrays defined by make_array are not included.

See also array, arrayapply, arrayinfo, arraymake, fillarray, listarray, and rearray.

(%i15) array(aa, 5, 7);
(%o15)                                aa
(%i16) bb[FOO] : (a + b)^2;
ARRSTORE: use_fast_arrays=false; allocate a new property hash table for $BB
                                          2
(%o16)                             (b + a)
(%i17) cc[x] := x/100;
                                          x
(%o17)                            cc  := ---
                                    x    100
(%i18) dd : make_array ('any, 7);
(%o18)           {Lisp Array: #(NIL NIL NIL NIL NIL NIL NIL)}
(%i19) arrays;
(%o19)                          [A, aa, bb, cc]

arraysetapply( A, [i_1, ..., i_n], x)
Assigns x to A[i_1, ..., i_n], where A is an array and i_1, ..., i_n are integers.

arraysetapply evaluates its arguments.

fillarray(A, B)
Fills array A from B, which is a list or an array.

If a specific type was declared for A when it was created, it can only be filled with elements of that same type; it is an error if an attempt is made to copy an element of a different type.

If the dimensions of the arrays A and B are different, A is filled in row-major order.

If there are not enough elements in B the last element is used to fill out the rest of A. If there are too many, the remaining ones are ignored.

fillarray returns its first argument.

Create an array of 9 elements and fill it from a list.

(%i20) array a1, fixnum, 8);
(%o20)                                a1
(%i21) listarray(a1);
(%o21)                    [0, 0, 0, 0, 0, 0, 0, 0, 0]
(%i22) fillarray(a1, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
(%o22)                                a1
(%i23) listarray(a1);
(%o23)                    [1, 2, 3, 4, 5, 6, 7, 8, 9]

When there are too few elements to fill the array, the last element is repeated. When there are too many elements, the extra elements are ignored.

(%i24) a2 : make_array(fixnum, 8);
(%o24)                 {Lisp Array: #(0 0 0 0 0 0 0 0)}
(%i25) fillarray(a2, [1, 2, 3, 4, 5]);
(%o25)                 {Lisp Array: #(1 2 3 4 5 5 5 5)}
(%i26) fillarray(a2, [4]);
(%o26)                 {Lisp Array: #(4 4 4 4 4 4 4 4)}
(%i27) fillarray(a2, makelist (i, i, 1, 100));
(%o27)                 {Lisp Array: #(1 2 3 4 5 6 7 8)}

Multple-dimension arrays are filled in row-major order.

(%i28) a3 : make_array (fixnum, 2, 5);
(%o28)            {Lisp Array: #2A((0 0 0 0 0) (0 0 0 0 0))}
(%i29) fillarray(a3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
(%o29)            {Lisp Array: #2A((1 2 3 4 5) (6 7 8 9 10))}
(%i30) a4 : make_array (fixnum, 5, 2);
(%o30)         {Lisp Array: #2A((0 0) (0 0) (0 0) (0 0) (0 0))}
(%i31) fillarray(a4, a3);
(%o31)         {Lisp Array: #2A((1 2) (3 4) (5 6) (7 8) (9 10))}

Maxima – 27 – Tipi di dati e strutture – arrays – 1

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.86.

array(name, dim_1, ..., dim_n)
array(name, type, dim_1, ..., dim_n)
array([name_1, ..., name_m], dim_1, ..., dim_n)
Creates an n-dimensional array. n may be less than or equal to 5. The subscripts for the i’th dimension are the integers running from 0 to dim_i.

array(name, dim_1, ..., dim_n) creates a general array.

array(name, type, dim_1, ..., dim_n) creates an array, with elements of a specified type. type can be fixnum for integers of limited size or flonum for floating-point numbers.

array([name_1, ..., name_m], dim_1, ..., dim_n) creates m arrays, all of the same dimensions.

If the user assigns to a subscripted variable before declaring the corresponding array, an undeclared array is created. Undeclared arrays, otherwise known as hashed arrays (because hash coding is done on the subscripts), are more general than declared arrays. The user does not declare their maximum size, and they grow dynamically by hashing as more elements are assigned values. The subscripts of undeclared arrays need not even be numbers. However, unless an array is rather sparse, it is probably more efficient to declare it when possible than to leave it undeclared. The array function can be used to transform an undeclared array into a declared array.

arrayapply(A, [i_1, ... , i_n])
Evaluates A [i_1, ..., i_n], where A is an array and i_1, ..., i_n are integers.

This is reminiscent of apply, except the first argument is an array instead of a function.

arrayinfo(A)
Returns information about the array A. The argument A may be a declared array, an undeclared (hashed) array, an array function, or a subscripted function.

For declared arrays, arrayinfo returns a list comprising the atom declared, the number of dimensions, and the size of each dimension. The elements of the array, both bound and unbound, are returned by listarray.

For undeclared arrays (hashed arrays), arrayinfo returns a list comprising the atom hashed, the number of subscripts, and the subscripts of every element which has a value. The values are returned by listarray.

For array functions, arrayinfo returns a list comprising the atom hashed, the number of subscripts, and any subscript values for which there are stored function values. The stored function values are returned by listarray.

For subscripted functions, arrayinfo returns a list comprising the atom hashed, the number of subscripts, and any subscript values for which there are lambda expressions. The lambda expressions are returned by listarray.

See also listarray.

arrayinfo and listarray applied to a declared array.

(%i1) array(aa, 2, 3);
(%o1)                                 aa
(%i2) aa[2, 3] : %pi;
(%o2)                                 %pi
(%i3) aa[1, 2] : %e;
(%o3)                                 %e
(%i4) arrayinfo(aa);
(%o4)                        [declared, 2, [2, 3]]
(%i5) listarray(aa);
(%o5) [#####, #####, #####, #####, #####, #####, %e, #####, #####, #####,
                                                                    #####, %pi]

arrayinfo and listarray applied to an undeclared (hashed) array.

(%i6) bb[FOO] : (a + b)^2;
ARRSTORE: use_fast_arrays=false; allocate a new property hash table for $BB
                                          2
(%o6)                              (b + a)
(%i7) bb[BAR] : (c - d)^3;
                                          3
(%o7)                              (c - d)
(%i8) arrayinfo(bb);
(%o8)                      [hashed, 1, [BAR], [FOO]]
(%i9) listarray(bb);
                                     3         2
(%o9)                        [(c - d) , (b + a) ]

arrayinfo and listarray applied to an array function.

(%i10) cc[x, y] := y / x;
                                            y
(%o10)                            cc     := -
                                    x, y    x
(%i11) cc[u, v];
                                       v
(%o11)                                 -
                                       u
(%i12) cc[4, z];
                                       z
(%o12)                                 -
                                       4
(%i13) arrayinfo(cc);
(%o13)                    [hashed, 2, [4, z], [u, v]]
(%i14) listarray(cc);
                                     z  v
(%o14)                              [-, -]
                                     4  u

arrayinfo and listarray applied to a subscripted function.

(%i15) dd [x] (y) := y ^ x;
                                            x
(%o15)                           dd (y) := y
                                   x
(%i16) dd [a + b];
                                           b + a
(%o16)                        lambda([y], y     )
(%i17) dd [v - u];
                                           v - u
(%o17)                        lambda([y], y     )
(%i18) arrayinfo(dd);
(%o18)                   [hashed, 1, [b + a], [v - u]]
(%i19) listarray(dd);
                                b + a                v - u
(%o19)            [lambda([y], y     ), lambda([y], y     )]

Maxima – 26 – considerazioni di prestazione per le liste

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.84.

Lists provide efficient ways of appending and removing elements. They can be created without knowing their final dimensions. Lisp provides efficient means of copying and handling lists. Also nested lists do not need to be strictly rectangular. These advantages over declared arrays come with the drawback that the amount of time needed for accessing a random element within a list may be roughly proportional to the element’s distance from its beginning. Efficient traversal of lists is still possible, though, by using the list as a stack or a fifo:

(%i1) l:[Test,1,2,3,4];
(%o1)                         [Test, 1, 2, 3, 4]
(%i2) while l # [] do
        disp(pop(l));
                                     Test

                                       1

                                       2

                                       3

                                       4

(%o2)                                done

Another even faster example would be:

(%i3) l:[Test,1,2,3,4];
(%o3)                         [Test, 1, 2, 3, 4]
(%i4) for i in l do
        disp(pop(l));
                                     Test

                                       1

                                       2

                                       3

                                       4

(%o4)                                done

Beginning traversal with the last element of a list is possible after reversing the list using reverse(). If the elements of a long list need to be processed in a different order performance might be increased by converting the list into a declared array first.

It is also to note that the ending condition of for loops is tested for every iteration which means that the result of a length should be cached if it is used in the ending condition:

(%i1) l: makelist(i, i, 1, 100000)$

(%i2) lngth: length(l);
(%o2)                               100000
(%i3) x: 1;
(%o3)                                  1
(%i4) for i: 1 thru lngth do
        x: x + 1$

(%i5) x;
(%o5)                               100001

OK, niente di nuovo.
Una osservazione mia (anticipazione) 😁

(%i1) l: [Test, 1, 2, 3, 4];
(%o1)                         [Test, 1, 2, 3, 4]
(%i2) s: 0;
(%o2)                                  0
(%i3) for i: 2 thru 5 do s: s + l[i]$

(%i4) s;
(%o4)                                 10

Sì, tutto come previsto 😁

Visto nel Web – 354

Quasi ora di tornare all’attività normale; intanto ecco cosa ho wisto nel Web 😜

Julia 1.0 Released After a Six-Year Wait
linguaggi di programmazione
::: Slashdot ::: jakevdp

Facebook is spending an extra $10 million a year to keep Mark Zuckerberg safe
protagonisti | Facebook
::: FortuneMagazine

Alex Jones is shirtlessly screaming into the void on popular social network Google+
social media | caos informativo, fake news, bufale
::: Gizmodo ::: Slate

“Twitter is early in the process, [@jack] said.” Come on. Safety has been declared a “top-priority” for the whole company several times in the past two and a half to three years, at least. Early in the latest round caused by the latest crises, perhaps
privacy, sicurezza, spionaggio, virus | Twitter
::: peterseibel ::: NiemanLab

World’s Largest Chip Maker Will Lose $250M For Not Patching Windows 7 Computers
privacy, sicurezza, spionaggio, virus | economia | sistemi operativi
::: Slashdot

Researchers Disclose New ‘Inverse Spectre Attack’
privacy, sicurezza, spionaggio, virus
::: Slashdot

A better question: how do you fix connected humanity?
Facebook | social media
::: fabiochiusi

Faces Are Being Scanned At US Airports With No Safeguards on Data Use
privacy, sicurezza, spionaggio, virus
::: Slashdot

At @defcon hacking conference and just learned how easy it is to physically gain admin access on a voting machine that is used in 18 states
privacy, sicurezza, spionaggio, virus
::: RachelTobac

IBM introduced its PC #otd in 1981. The “5150” used MS-DOS & ran w/a 4.77 MHz Intel 8088 microprocessor. It cost $6K, or almost $15K in today’s dollars
storia
::: MIT_CSAIL

The race to 5G
innovazioni, futuro
::: IEEESpectrum

Another interesting post where PVS-Studio explores running their tool on a major open source project, this time Android
bug | dispositivi mobili
::: _wilfredh

The Cost Of JavaScript In 2018
linguaggi di programmazione | privacy, sicurezza, spionaggio, virus
::: stevesi

How Two Years of Instagram Stories Has Altered the Way We Love, Act and Play
social media
::: Gianlucadfiore

Beautiful maps in minutes: Meet http://Kepler.gl
tools, componenti software
::: cialunet

11-Year-Old Changes Election Results On Florida’s Website: Defcon 2018
privacy, sicurezza, spionaggio, virus | politica
::: Slashdot

Mastodon – È come Twitter ma più bello
social media
::: yoshi979

12 cose che dovresti cancellare subito dal tuo profilo Facebook
social media
::: wireditalia

Julian Assange just lost one of his few remaining allies
Web, Internet
::: NoahShachtman

Linux 4.18 Arrives With Some Big Changes
sistemi operativi
::: dcavedon

Many Google Services on Android Devices and iPhones Store Location Data, Even if Location Sharing is Disabled From Privacy Settings
dispositivi mobili | privacy, sicurezza, spionaggio, virus
::: Slashdot

Hacked Water Heaters Could Trigger Mass Blackouts Someday
privacy, sicurezza, spionaggio, virus
::: Slashdot

The Digital Currency Initiative’s Cory Fields writes about his experience disclosing a critical (and now fixed) Bitcoin Cash vulnerability
privacy, sicurezza, spionaggio, virus
::: medialab

Apple Asked Developers To Adopt Subscriptions and Hike App Prices, Report Says
ditte | economia
::: Slashdot

The dangers of AVX-512 throttling: myth or reality?
programming, codice, snippet
::: lemire

Internet Engineering Task Force Releases the Final Version of TLS 1.3; Newest Chrome and Firefox Versions Already Support a Draft Version of It
Web, Internet | privacy, sicurezza, spionaggio, virus
::: Slashdot

Quick case study on open source documentation…
Python | documenti
::: jakevdp

FastPriorityQueue.js: a fast heap-based priority queue in JavaScript (version 0.6.0)
linguaggi di programmazione
::: lemire

How Software Developers Use Twitter
Twitter
::: RichRogersIoT

Google says you can turn off its location tracking services on your phone at any time. And by “you can”, Google means you can’t
Google | privacy, sicurezza, spionaggio, virus
::: AntonioCasilli

Australia To Pass Bill Providing Backdoors Into Encrypted Devices, Communications
privacy, sicurezza, spionaggio, virus
::: Slashdot

FBI Warns of ‘Unlimited’ ATM Cashout Scheme
frodi
::: Slashdot

Zuckerberg Doesn’t Care About Publishers; Media Firms That Don’t Work With Us Will End Up ‘In Hospice’: Facebook Executive
Facebook | media
::: Slashdot

Is it just me or is Facebook feeling more and more like a ghosttown
Facebook
::: kevinbaker

Twitter is making changes that will break or degrade a number of features in Tweetbot and other clients
Twitter
::: tapbots ::: zooba ::: jaredgaut

Hacking the Fax – Ground Breaking New Research in Cyber – YouTube
privacy, sicurezza, spionaggio, virus
::: stecb

USB Charging Actually Poses Security Risks – Hacking a Laptop via a USB-C Adapter
privacy, sicurezza, spionaggio, virus
::: cnxsoft

The distinction between platforms and publishers gets muddier every day. Facebook strikes deal with Spain’s La Liga “which will allow viewers in the Indian sub-continent to watch every game over the next three seasons for free on the social network”
Facebook
::: rasmus_kleis

In order to visualize an algorithm, we don’t merely fit data to a chart: there are logical rules that describe behavior
algoritmi, codice
::: Rainmaker1973

Hot off the presses! My new @NYTmag cover story about Silicon Valley’s war on privacy
economia
::: nickconfessore

Sep12 the EU votes on a law that is good for copyright owners, but bad for education. Ask EU to #FixCopyright4Edu and not to treat education as a private commodity
copyright e brevetti
::: communia_eu

I wrote a gentle guide to all things WebAssembly!🤓
linguaggi di programmazione
::: bibydigital

Hundreds of Researchers From Harvard, Yale and Stanford Were Published in Fake Academic Journals
caos informativo, fake news, bufale | media
::: Slashdot

Intel Discloses Three More Chip Flaws
privacy, sicurezza, spionaggio, virus | hardware
::: Slashdot

Altair version 2.2 just released! This adds support to Vega-Lite 2.6, as well as offering a number of API improvements, bug fixes, new examples, and documentation updates
Python
::: jakevdp

I see excellent research results reported by @fb_research, but no discussion of the egregious privacy violations that funded the work. See https://nbcnews.to/2pAI42E for a sample. $fb is a bad actor, and Facebook researchers could lead the fight to reform it
Facebook
::: etzioni

Software friends! how much do you read (books) about our craft, startups, leadership, sales, marketing, etc every year?
documenti
::: steyblind

Vue.js Tutorial for beginners
linguaggi di programmazione
::: Gianlucadfiore

Apple Argued That Buildings at Its Headquarters Were Worth $200, Not $1B, To Reduce Its Tax Bill: Report
ditte
::: Slashdot

Monolithic OS Design Is Flawed
Microkernel-based Designs Improve Security
sistemi operativi
::: johnregehr ::: _wilfredh

Microsoft and Amazon Begin Public Rollout of First Alexa-Cortana Integrations
Web, Internet
::: Slashdot

How Facebook and Google Win By Embedding in Political Campaigns
politica
::: fabiochiusi

Americans Don’t Think the Platforms Are Doing Enough To Fight Fake News
caos informativo, fake news, bufale
::: Slashdot

How William Shockley’s Robot Dream Helped Launch Silicon Valley
storia
::: IEEESpectrum

A Look at Facebook’s Presence in Myanmar Where Despite Public Outcries, Facebook is Still Struggling To Contain Hate Speech
Facebook | odio, razzismo, discriminazioni
::: Slashdot ::: fabiochiusi

There’s no guarantee that today’s fixed networks can meet the guarantees of #5G, says the chairman of a new @ITU focus group
dispositivi mobili
::: IEEESpectrum

Technology is never neutral. That’s why awareness of ethics is so essential
tutto il thread, fin da sopra
Twitter
::: fchollet

The dangers of AVX-512 throttling: a 3% impact
privacy, sicurezza, spionaggio, virus
::: lemire

Zorin OS 12.4 Released, Available to Download Now
Linux distro
::: dcavedon

TensorFlow has a lot to offer
linguaggi di programmazione
::: fchollet ::: aureliengeron ::: Ed_Forson

The Myth of Metaphor
uh! quel Cooper, quello del VB con la versione ammodernata di una roba del ’95 (ricordo perfettamente (kwasy))
programming, codice, snippet
::: MrAlanCooper

Police Bodycams Can Be Hacked To Doctor Footage, Install Malware
privacy, sicurezza, spionaggio, virus
::: Slashdot

Feedback-Directed Differential Testing of Interactive Debuggers
programming, codice, snippet
::: johnregehr

Twitter CEO Jack Dorsey spoke with me + @lizzadwoskin today about the things his company is going to have to do to stop fake news, hate, harassment and more. Wide ranging DC interview before he is set to testify to Congress in Sept
Twitter
::: TonyRomm

The French government has launched an initiative that aims at establishing a new ‘general regulatory framework for the digital giants’. It’s asking some interesting and difficult questions, all of which necessitate a multistakeholder process
Web, Internet
::: Bennetto90

This is interesting: the majority dislikes algorithmic curation of content > “54 percent said internet content curated by the companies’ algorithms is a bad idea (including 16 percent who felt it is a “very bad” idea), while 45 percent thought it was good”
caos informativo, fake news, bufale
::: fabiochiusi

Post-GDPR, major news sites across 7 EU countries load 22% fewer third party cookies
Web, Internet
::: rasmus_kleis

Tempo un paio d’anni e su Facebook rimarranno solo i vecchi
Facebook
::: mante

25 years and counting #DebianDay
auguri 🎉🎉🎉
Linux distro
::: debian

July UK newspaper circulation figures out, with % year
media
::: MarkDiStef

Last night I did a mini game jam where I wrote a complete version of Tetris in @racketlang and the Lux library from start to finish
nota per me: il codice raggiungibile passando per Mastodon; decollerà?
language Racket
::: dustyweb

It was the first of many attempts by the AT&T lawyers to justify their existence and to kill UNIX
storia
::: wallingf

China’s ‘First Fully Homegrown’ Web Browser, Used By Key Government Bodies, Under Fire For ‘Heavily’ Copying Google Chrome Files
Web, Internet
::: Slashdot

Trump wants to make it easier for U.S. to launch cyberattacks
privacy, sicurezza, spionaggio, virus
::: vicenews

What I want in my timeline is
Twitter
::: KCoxDC

C17 is a “bugfix release” of the C standard
linguaggi di programmazione
::: b3h3m0th ::: b3h3m0th ::: b3h3m0th ::: b3h3m0th

I have been asked several times over the last few weeks to solve problems that yielded (lol) to monad transformers. Yes there are other ways, but let’s start here. I came across this very readable introduction by @gabro27 so check it out
programmazione funzionale
::: channingwalton

Twitter’s Relationship With Third-Party Apps is Messy — But It’s Not Over
Twitter
::: Slashdot

I spy an Altair plot in this post about @ProjectJupyter notebooks
Python
::: jakevdp

Because we were caught red-handed lying to the world, we’re now forced to admit that, yes, we track your every move, without your permission, with no option to opt out. Hope this clarifies things
Google
::: AmandaLeeHouse

The Senate just unanimously passed a resolution affirming that the Press isn’t the ‘enemy of the people’
media
::: krassenstein

Google Employees Protest Secret Work on Censored Search Engine for China
censura
::: fabiochiusi ::: azuech ::: Slashdot

Cloudgizer: An introduction to a new open source web development tool
linguaggi di programmazione
::: cialunet

Discover “Unpaywall,” a New (and Legal) Browser Extension That Lets You Read Millions of Science Articles Normally Locked Up Behind Paywalls
Web, Internet | open source
::: marcodelmastro

“If you have anyone who can do a better job, please let me know. They can have the job.” — This remarkable, raw interview with ⁦@elonmusk⁩ is a must-read
protagonisti
::: bencasselman

Mozilla Removes 23 Firefox Add-Ons That Snooped On Users
privacy, sicurezza, spionaggio, virus
::: Slashdot

NSA Cracked Open Encrypted Networks of Russian Airlines, Al Jazeera, and Other ‘High Potential’ Targets
privacy, sicurezza, spionaggio, virus
::: Slashdot

Lessons Learned in Software Development
vecchio ma OK
programming, codice, snippet
::: RichRogersIoT

US Government Seeks Facebook Help To Wiretap Messenger, Report Says
privacy, sicurezza, spionaggio, virus
::: Slashdot ::: fabiochiusi

A really fun project: installing uLisp on an Arduino Due, making it talk to a typewriter, and then writing an editor for the setup
lisp(s) | hardware
::: _wilfredh

Facebook Flat-Out ‘Lies’ About How Many People Can See Its Ads, Lawsuit Alleges
Facebook | ad, pubblicità
::: Slashdot

Questo mio post su #Tumbrl (semplici #disegni) è stato considerato spam su #Google+ e rimosso, mentre su #Facebook non appare l’anteprima dell’immagine né il titolo
caso tipico di prestare attenzione a quel che si vede per meno di un microsecondo
social media
::: patfumetto

GoAWK: an AWK interpreter written in Go
linguaggi di programmazione
::: Gianlucadfiore

Tips on using the Curl Command in Linux
Web, Internet
::: Gianlucadfiore

Were We Destined to Live in Facebook’s World?
The power of an ideology that says social engineering is possible and therefore, we should do it—that’s pretty irresistible to a bunch of idealistic, half-educated young people
Facebook
::: sivavaid

Easy to forget how some digital freedoms we take for granted today, like PGP, was fought for by people in the past
privacy, sicurezza, spionaggio, virus
::: amasad

Someone in London is paying good money to troll Facebook
Facebook
::: JaneLytv

This ✨magical link✨ shows your Twitter timeline in true chronological order—without retweets, liked tweets, or any algorithm nonsense
appena provato, sembra OK
Twitter
::: waxpancake

EU Accepts Resolution Abolishing Planned Obsolescence, Making Devices Easier to Repair
hardware | economia
::: Slashdot

Maxima – 25 – Tipi di dati e strutture – liste – 6

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.82.

sublist(list, p)
Returns the list of elements of list for which the predicate p returns true.

(%i1) L: [1, 2, 3, 4, 5, 6];
(%o1)                         [1, 2, 3, 4, 5, 6]
(%i2) sublist(L, evenp);
(%o2)                              [2, 4, 6]

sublist_indices(L, P)
Returns the indices of the elements x of the list L for which the predicate maybe(P(x)) returns true; this excludes unknown as well as false. P may be the name of a function or a lambda expression. L must be a literal list.

(%i3) sublist_indices('[a, b, b, c, 1, 2, b, 3, b], lambda ([x], x='b));
(%o3)                            [2, 3, 7, 9]
(%i4) sublist_indices('[a, b, b, c, 1, 2, b, 3, b], symbolp);
(%o4)                         [1, 2, 3, 4, 7, 9]
(%i5) sublist_indices([1 > 0, 1 < 0, 2 < 1, 2 > 1, 2 > 0], identity);
(%o5)                              [1, 4, 5]
(%i6) assume (x < -1);
(%o6)                              [x < - 1] 
(%i7) map(maybe, [x > 0, x < 0, x < -2]); 
(%o7)                         [false, true, unknown] 
(%i8) sublist_indices([x > 0, x < 0, x < -2], identity);
(%o8)                                 [2]

tree_reduce(F, s)
tree_reduce(F, s, s_0)
Extends the binary function F to an n-ary function by composition, where s is a set or list.

tree_reduce is equivalent to the following: Apply F to successive pairs of elements to form a new list [F(s_1, s_2), F(s_3, s_4), ...], carrying the final element unchanged if there are an odd number of elements. Then repeat until the list is reduced to a single element, which is the return value.

When the optional argument s_0 is present, the result is equivalent tree_reduce(F, cons(s_0, s)).

For addition of floating point numbers, tree_reduce may return a sum that has a smaller rounding error than either rreduce or lreduce.

The elements of s and the partial results may be arranged in a minimum-depth binary tree, thus the name “tree reduce”.

tree_reduce applied to a list with an even number of elements.

(%i9) tree_reduce(f, [a, b, c, d]);
(%o9)                         f(f(a, b), f(c, d))

tree_reduce applied to a list with an odd number of elements.

(%i10) tree_reduce(f, [a, b, c, d, e]);
(%o10)                     f(f(f(a, b), f(c, d)), e)

unique(L)
Returns the unique elements of the list L.

When all the elements of L are unique, unique returns a shallow copy of L, not L itself.

If L is not a list, unique returns L.

(%i11) unique([1, %pi, a + b, 2, 1, %e, %pi, a + b, [1]]);
(%o11)                    [1, 2, %e, %pi, [1], b + a]

xreduce(F, s)
xreduce(F, s, s_0)
Extends the function F to an n-ary function by composition, or, if F is already n-ary, applies F to s. When F is not n-ary, xreduce is the same as lreduce. The argument s is a list.

Functions known to be n-ary include addition +, multiplication *, and, or, max, min, and append. Functions may also be declared n-ary by declare(F, nary). For these functions, xreduce is expected to be faster than either rreduce or lreduce.

When the optional argument s_0 is present, the result is equivalent to xreduce(s, cons(s_0, s)).

Floating point addition is not exactly associative; be that as it may, xreduce applies Maxima’s n-ary addition when s contains floating point numbers.

xreduce applied to a function known to be n-ary. F is called once, with all arguments.

(%i12) declare(F, nary);
(%o12)                               done
(%i13) F([L]) := L;
(%o13)                            F([L]) := L
(%i14) xreduce(F, [a, b, c, d, e]);
(%o14)                          [a, b, c, d, e]

xreduce applied to a function not known to be n-ary. G is called several times, with two arguments each time.

(%i15) G([L]) := L;
(%o15)                            G([L]) := L
(%i16) xreduce(G, [a, b, c, d, e]);
(%o16)                       [[[[a, b], c], d], e]
(%i17) lreduce(G, [a, b, c, d, e]);
(%o17)                       [[[[a, b], c], d], e]

Maxima – 24 – Tipi di dati e strutture – liste – 5

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.77.

pop(list)
pop removes and returns the first element from the list list. The argument list must be a mapatom that is bound to a nonempty list. If the argument list is not bound to a nonempty list, Maxima signals an error.

push (item, list)
push prepends the item item to the list list and returns a copy of the new list. The second argument list must be a mapatom that is bound to a list. The first argument item can be any Maxima symbol or expression. If the argument list is not bound to a list, Maxima signals an error.

To remove the first item from a list, see pop.

(%i1) ll: [];
(%o1)                                 []
(%i2) push (x, ll);
(%o2)                                 [x]
(%i3) push (x^2+y, ll);
                                        2
(%o3)                             [y + x , x]
(%i4) a: push ("string", ll);
                                            2
(%o4)                         [string, y + x , x]
(%i5) pop (ll);
(%o5)                               string
(%i6) pop (ll);
                                         2
(%o6)                               y + x
(%i7) pop (ll);
(%o7)                                  x
(%i8) ll;
(%o8)                                 []
(%i9) a;
                                            2
(%o9)                         [string, y + x , x]

rest(expr, n)
rest(expr)
Returns expr with its first n elements removed if n is positive and its last - n elements removed if n is negative. If n is 1 it may be omitted. The first argument expr may be a list, matrix, or other expression. When expr is an atom, rest signals an error; when expr is an empty list and partswitch is false, rest signals an error. When expr is an empty list and partswitch is true, rest returns end.

Applying rest to expression such as f(a,b,c) returns f(b,c). In general, applying rest to an nonlist doesn’t make sense. For example, because ’^’ requires two arguments, rest(a^b) results in an error message. The functions args and op may be useful as well, since args(a^b) returns [a,b] and op(a^b) returns ^.

See also firstn and lastn.

(%i1) rest(a+b+c);
(%o1)                                b + a
(%i2) rest(a+b+c,2);
(%o2)                                  a
(%i3) rest(a+b+c,-2);
(%o3)                                  c

reverse(list)
Reverses the order of the members of the list (not the members themselves). reverse also works on general expressions, e.g. reverse(a=b); gives b=a.

rreduce(F, s)
rreduce(F, s, s_{n + 1})
Extends the binary function F to an n-ary function by composition, where s is a list.

rreduce(F, s) returns F(s_1, ... F(s_{n - 2}, F(s_{n - 1}, s_n))).

When the optional argument s{ n + 1} is present, the result is equivalent to rreduce(F, endcons(s_{n + 1}, s)).

The function F is first applied to the rightmost list elements, thus the name “rreduce”.

rreduce without the optional argument.

(%i4) rreduce(f, [1, 2, 3]);
(%o4)                            f(1, f(2, 3))
(%i5) rreduce(f, [1, 2, 3, 4]);
(%o5)                         f(1, f(2, f(3, 4)))

rreduce with the optional argument.

(%i6) rreduce (f, [1, 2, 3], 4);
(%o6)                         f(1, f(2, f(3, 4)))

rreduce applied to built-in binary operators. / is the division operator.

(%i7) rreduce ("^", args({a, b, c, d}));
                                        d
                                       c
                                      b
(%o7)                                a
(%i8) rreduce ("/", args({a, b, c, d}));
                                      a c
(%o8)                                 ---
                                      b d

sort(L, P)
sort(L)
sort(L, P) sorts a list L according to a predicate P of two arguments which defines a strict weak order on the elements of L. If P(a, b) is true, then a appears before b in the result. If neither P(a, b) nor P(b, a) are true, then a and b are equivalent, and appear in the result in the same order as in the input. That is, sort is a stable sort.

If P(a, b) and P(b, a) are both true for some elements of L, then P is not a valid sort predicate, and the result is undefined. If P(a, b) is something other than true or false, sort signals an error.

The predicate may be specified as the name of a function or binary infix operator, or as a lambda expression. If specified as the name of an operator, the name must be enclosed in double quotes.

The sorted list is returned as a new object; the argument L is not modified.

sort(L) is equivalent to sort(L, orderlessp).

The default sorting order is ascending, as determined by orderlessp. The predicate ordergreatp sorts a list in descending order.

All Maxima atoms and expressions are comparable under orderlessp and ordergreatp.

Operators < and > order numbers, constants, and constant expressions by magnitude. Note that orderlessp and ordergreatp do not order numbers, constants, and constant expressions by magnitude.

ordermagnitudep orders numbers, constants, and constant expressions the same as <, and all other elements the same as orderlessp.

sort sorts a list according to a predicate of two arguments which defines a strict weak order on the elements of the list.

(%i9) sort([1, a, b, 2, 3, c], 'orderlessp);
(%o9)                         [1, 2, 3, a, b, c]
(%i10) sort([1, a, b, 2, 3, c], 'ordergreatp);
(%o10)                        [c, b, a, 3, 2, 1]

The predicate may be specified as the name of a function or binary infix operator, or as a lambda expression. If specified as the name of an operator, the name must be enclosed in double quotes.

(%i11) L : [[1, x], [3, y], [4, w], [2, z]];
(%o11)                 [[1, x], [3, y], [4, w], [2, z]]
(%i12) foo(a, b) := a[1] > b[1];
(%o12)                       foo(a, b) := a  > b
                                           1    1
(%i13) sort(L, 'foo);
(%o13)                 [[4, w], [3, y], [2, z], [1, x]]
(%i14) infix(">>");
(%o14)                                >>
(%i15) a >> b := a[1] > b[1];
(%o15)                        (a >> b) := a  > b
                                           1    1
(%i16) sort(L, ">>");
(%o16)                 [[4, w], [3, y], [2, z], [1, x]]
(%i17) sort(L, lambda([a, b], a[1] > b[1]));
(%o17)                 [[4, w], [3, y], [2, z], [1, x]]

sort(L) is equivalent to sort(L, orderlessp).

(%i18) L : [a, 2*b, -5, 7, 1 + %e, %pi];
(%o18)                   [a, 2 b, - 5, 7, %e + 1, %pi]
(%i19) sort(L);
(%o19)                   [- 5, 7, %e + 1, %pi, a, 2 b]
(%i20) sort(L, 'orderlessp);
(%o20)                   [- 5, 7, %e + 1, %pi, a, 2 b]

The default sorting order is ascending, as determined by orderlessp. The predicate ordergreatp sorts a list in descending order.

(%i21) L : [a, 2*b, -5, 7, 1 + %e, %pi];
(%o21)                   [a, 2 b, - 5, 7, %e + 1, %pi]
(%i22) sort(L);
(%o22)                   [- 5, 7, %e + 1, %pi, a, 2 b]
(%i23) sort(L, 'ordergreatp);
(%o23)                   [2 b, a, %pi, %e + 1, 7, - 5]

All Maxima atoms and expressions are comparable under orderlessp and ordergreatp.

(%i1) L : [11, -17, 29b0, 9*c, 7.55, foo(x, y), -5/2, b + a];
                                                        5
(%o1)         [11, - 17, 2.9b1, 9 c, 7.55, foo(x, y), - -, b + a]
                                                        2
(%i2) sort(L, orderlessp);
                       5
(%o2)         [- 17, - -, 7.55, 11, 2.9b1, b + a, 9 c, foo(x, y)]
                       2
(%i3) sort(L, ordergreatp);
                                                         5
(%o3)         [foo(x, y), 9 c, b + a, 2.9b1, 11, 7.55, - -, - 17]
                                                         2

Operators < and > order numbers, constants, and constant expressions by magnitude. Note that orderlessp and ordergreatp do not order numbers, constants, and constant expressions by magnitude.

(%i4) L : [%pi, 3, 4, %e, %gamma];
(%o4)                       [%pi, 3, 4, %e, %gamma]
(%i5) sort(L, ">");
(%o5)                       [4, %pi, 3, %e, %gamma]
(%i6) sort(L, ordergreatp);
(%o6)                       [%pi, %gamma, %e, 4, 3]

ordermagnitudep orders numbers, constants, and constant expressions the same as <, and all other elements the same as orderlessp.

(%i7) L : [%i, 1+%i, 2*x, minf, inf, %e, sin(1), 0, 1, 2, 3, 1.0, 1.0b0];
(%o7)  [%i, %i + 1, 2 x, minf, inf, %e, sin(1), 0, 1, 2, 3, 1.0, 1.0b0]
(%i8) sort(L, ordermagnitudep);
(%o8)  [minf, 0, sin(1), 1, 1.0, 1.0b0, 2, %e, 3, inf, %i, %i + 1, 2 x]
(%i9) sort(L, orderlessp);
(%o9)  [0, 1, 1.0, 2, 3, %e, %i, %i + 1, inf, minf, sin(1), 1.0b0, 2 x]

Nota mia di cui non so bene la risposta: il predicato si può quotare con ' ma anche no; sembra, da appurare in futuro.

(%i1) L : [3, 5, 7, 1, 2, 4, 6, 8, 0];
(%o1)                     [3, 5, 7, 1, 2, 4, 6, 8, 0]
(%i2) sort(L, orderlessp);
(%o2)                     [0, 1, 2, 3, 4, 5, 6, 7, 8]
(%i3) sort(L, 'orderlessp);
(%o3)                     [0, 1, 2, 3, 4, 5, 6, 7, 8]

AI, innovazioni e blockchain – 35

Dai che abbiamo passato Ferragosto, ora di riprendere. Intanto ecco qua 😁

Anki’s Vector Is a Little AI-Powered Robot Now on Kickstarter for $200
robots
::: IEEESpectrum

Blockchain Hype May Have Peaked, But IBM is Still a Believer
blockchain e crypto*
::: Slashdot

Baltimore Police Department Is Still Using Lotus Notes
innovazioni, futuro
::: Slashdot

A simple Neural Network built from scratch using Repl.it
Python
::: HayaOdeh

Extreme automation: How new digital health initiative can save billions in global healthcare costs
automazione
::: ieeeitpro

The World Bank is Preparing For the World’s First Blockchain Bond
blockchain e crypto*
::: Slashdot

A Small Team of Student AI Coders Beats Google’s Machine-Learning Code
artificial intelligence | algoritmi, codice
::: Slashdot

Tesla’s Chief Vehicle Engineer Returns To Apple
innovazioni, futuro
::: Slashdot

Scribit is a write & erase robot that allows you to draw any content sourced from the web – and update it in real time
robots
::: Rainmaker1973

How China’s empire of money is reshaping global trade
innovazioni, futuro | economia
::: business

Il nuovo laboratorio italiano di Intelligenza Artificiale spiegato dal suo direttore
artificial intelligence
::: Agenzia_Italia

Cryptocurrency Markets Lost $18 Billion Overnight
blockchain e crypto*
::: Slashdot ::: nic__carter

From the “How not to use the blockchain handbook”
blockchain e crypto*
::: Gianlucadfiore

In Silicon Valley, engineers are king. So when your engineers tell you there’s a problem, you listen
innovazioni, futuro | economia
::: WIRED

Researchers Use Machine-Learning Techniques To De-Anonymize Coders
machine learning
::: Slashdot

The new WSJ article on IBM Watson Health’s setbacks is a sober reminder that we need to set realistic expectations. AI will transform industries, but the path is not always obvious. I still hope Watson Health ultimately triumphs though
artificial intelligence
::: AndrewYNg ::: Slashdot

My old team Baidu DuerOS’ software is running on 100 million devices
artificial intelligence
::: AndrewYNg

Do Not Buy a Smartwatch Right Now
innovazioni, futuro
::: Slashdot

The 1st prospective clinical validation of #AI in medicine publication
artificial intelligence
::: EricTopol

Well, this is creepy. “About 3,000 Swedes have opted to insert grain-of-rice-sized microchips beneath the skin between their thumbs and index fingers”
innovazioni, futuro
::: Mantzarlis

Bitcoin Sinks Below $6,000 as Almost Everything Crypto Tumbles
blockchain e crypto*
::: Slashdot

The evolution of #Arpanet (1969-1989)
storia
::: Rainmaker1973

Children ‘At Risk of Robot Influence’
robots | privacy, sicurezza, spionaggio, virus
::: Slashdot

On Thursday Aug 30 I’ll be giving a talk at the @CERN Machine Learning forum about our recent work “Learning the likelihood function: moving from classification to inference”
machine learning
::: KyleCranmer

Haru: An Experimental Social Robot From Honda Research
robots
::: IEEESpectrum

robots attempting to perform basic tasks but instead getting in everyone’s way and just making the job harder is a fantastic metaphor for the state of robotics today
se ho capito un esame sullo stato dell’arte
robots
::: atroyn

how historically biased datasets can create discriminatory algorithms
web-bot
::: datasociety

You may be able to update your Facebook status from the moon one day
innovazioni, futuro
::: CNBC

Shhhh! I’ve blogged about Twitter’s secret “guest mode”
può essere un gioco per perder tempo
hackers at work
::: edent

These drones can plant 100,000 trees in a single day
innovazioni, futuro
::: MIT_CSAIL

Maxima – 23 – Tipi di dati e strutture – liste – 4

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.75.

length(expr)
Returns (by default) the number of parts in the external (displayed) form of expr.

For lists this is the number of elements, for matrices it is the number of rows, and for sums it is the number of terms (see dispform).

The length command is affected by the inflag switch. So, e.g. length(a/(b*c)); gives 2 if inflag is false (Assuming exptdispflag is true), but 3 if inflag is true (the internal representation is essentially a*b^-1*c^-1).

Determining a list’s length typically needs an amount of time proportional to the number of elements in the list. If the length of a list is used inside a loop it therefore might drastically increase the performance if the length is calculated outside the loop instead.

listarith
Default value: true
If false causes any arithmetic operations with lists to be suppressed; when true, list-matrix operations are contagious causing lists to be converted to matrices yielding a result which is always a matrix. However, list-list operations should return lists.

listp(expr)
Returns true if expr is a list else false.

lreduce(F, s)
lreduce(F, s, s_0)
Extends the binary function F to an n-ary function by composition, where s is a list.

lreduce(F, s) returns F(... F(F(s_1, s_2), s_3), ... s_n). When the optional argument s_0 is present, the result is equivalent to lreduce(F, cons(s_0, s)).

The function F is first applied to the leftmost list elements, thus the name “lreduce”.

See also rreduce, xreduce, and tree_reduce.

lreduce without the optional argument.

(%i1) lreduce(f, [1, 2, 3]);
(%o1)                            f(f(1, 2), 3)
(%i2) lreduce(f, [1, 2, 3, 4]);
(%o2)                         f(f(f(1, 2), 3), 4)

lreduce with the optional argument.
(%i3) lreduce("^", args ({a, b, c, d}));
                                      b c d
(%o3)                              ((a ) )
(%i4) lreduce ("/", args ({a, b, c, d}));
                                       a
(%o4)                                -----
                                     b c d

makelist()
makelist(expr, n)
makelist(expr, i, i_max)
makelist(expr, i, i_0, i_max)
makelist(expr, i, i_0, i_max, step)
makelist(expr, x, list)
The first form, makelist(), creates an empty list. The second form, makelist(expr), creates a list with expr as its single element. makelist(expr, n) creates a list of n elements generated from expr.

The most general form, makelist(expr, i, i_0, i_max, step), returns the list of elements obtained when ev(expr, i=j) is applied to the elements j of the sequence: i_0, i_0 + step, i_0 + 2*step, ..., with |j| less than or equal to |i_max|.

The increment step can be a number (positive or negative) or an expression. If it is omitted, the default value 1 will be used. If both i_0 and step are omitted, they will both have a default value of 1.

makelist(expr, x, list) returns a list, the j’th element of which is equal to ev(expr, x=list[j]) for j equal to 1 through length(list).

(%i5) makelist(concat (x,i), i, 6);
(%o5)                      [x1, x2, x3, x4, x5, x6]
(%i6) makelist(x=y, y, [a, b, c]);
(%o6)                        [x = a, x = b, x = c]
(%i7) makelist(x^2, x, 3, 2*%pi, 2);
(%o7)                               [9, 25]
(%i8) makelist(random(6), 4);
(%o8)                            [2, 0, 2, 5]
(%i9) flatten(makelist(makelist(i^2, 3), i, 4));
(%o9)               [1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16]
(%i10) flatten(makelist(makelist(i^2, i, 3), 4));
(%o10)               [1, 4, 9, 1, 4, 9, 1, 4, 9, 1, 4, 9]

da pensarci un po’ su.

member(expr_1, expr_2)
Returns true if is(expr_1 = a) for some element a in args(expr_2), otherwise returns false.

expr_2 is typically a list, in which case args(expr_2) = expr_2 and is (expr_1 = a) for some element a in expr_2 is the test.

member does not inspect parts of the arguments of expr_2, so it may return false even if expr_1 is a part of some argument of expr_2.

See also elementp.

(%i11) member(8, [8, 8.0, 8b0]);
(%o11)                               true
(%i12) member(8, [8.0, 8b0]);
(%o12)                               false
(%i13) member(b, [a, b, c]);
(%o13)                               true
(%i14) member(b, [[a, b], [b, c]]);
(%o14)                               false
(%i15) member([b, c], [[a, b], [b, c]]);
(%o15)                               true
(%i16) F(1, 1/2, 1/4, 1/8);
                                      1  1  1
(%o16)                           F(1, -, -, -)
                                      2  4  8
(%i17) member(1/8, %);
(%o17)                               true
(%i18) member("ab", ["aa", "ab", sin(1), a + b]);
(%o18)                               true

Maxima – 22 – Tipi di dati e strutture – liste – 3

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.72.

firstn(expr, count)
Returns the first count arguments of expr, if expr has at least count arguments. Returns expr if expr has less than count arguments.

expr may be any nonatomic expression. When expr is something other than a list, firstn returns an expression which has the same operator as expr. count must be a nonnegative integer.

firstn honors the global flag inflag, which governs whether the internal form of an expression is processed (when inflag is true) or the displayed form (when inflag is false)
.
Note that firstn(expr, 1), which returns a nonatomic expression containing the first argument, is not the same as first(expr), which returns the first argument by itself.

firstn returns the first count elements of expr, if expr has at least count elements.

(%i1) mylist : [1, a, 2, b, 3, x, 4 - y, 2*z + sin(u)];
(%o1)               [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]
(%i2) firstn(mylist, 0);
(%o2)                                 []
(%i3) firstn(mylist, 1);
(%o3)                                 [1]
(%i4) firstn(mylist, 2);
(%o4)                               [1, a]
(%i5) firstn(mylist, 7);
(%o5)                      [1, a, 2, b, 3, x, 4 - y]

firstn returns expr if expr has less than count elements.

(%i6) mylist : [1, a, 2, b, 3, x, 4 - y, 2*z + sin(u)];
(%o6)               [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]
(%i7) firstn(mylist, 100);
(%o7)               [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]

expr may be any nonatomic expression.

(%i8) myfoo : foo(1, a, 2, b, 3, x, 4 - y, 2*z + sin(u));
(%o8)             foo(1, a, 2, b, 3, x, 4 - y, 2 z + sin(u))
(%i9) firstn(myfoo, 4);
(%o9)                           foo(1, a, 2, b)
(%i10) mybar : bar[m, n](1, a, 2, b, 3, x, 4 - y, 2*z + sin(u));
(%o10)          bar    (1, a, 2, b, 3, x, 4 - y, 2 z + sin(u))
                   m, n
(%i11) firstn(mybar, 4);
(%o11)                        bar    (1, a, 2, b)
                                 m, n
(%i12) mymatrix : genmatrix (lambda ([i, j], 10*i + j), 10, 4) $

(%i13) firstn(mymatrix, 3);
                              [ 11  12  13  14 ]
                              [                ]
(%o13)                        [ 21  22  23  24 ]
                              [                ]
                              [ 31  32  33  34 ]

firstn honors the global flag inflag.

(%i14) myexpr : a + b + c + d + e;
(%o14)                         e + d + c + b + a
(%i15) firstn(myexpr, 3), inflag=true;
(%o15)                             c + b + a
(%i16) firstn(myexpr, 3), inflag=false;
(%o16)                             e + d + c

Note that firstn(expr, 1) is not the same as first(expr).

(%i17) firstn([w, x, y, z], 1);
(%o17)                                [w]
(%i18) first([w, x, y, z]);
(%o18)                                 w

join(l, m)
Creates a new list containing the elements of lists l and m, interspersed. The result has elements [l[1], m[1], l[2], m[2], ...]. The lists l and m may contain any type of elements.

If the lists are different lengths, join ignores elements of the longer list.

Maxima complains if l or m is not a list.

(%i19) L1: [a, sin(b), c!, d - 1];
(%o19)                      [a, sin(b), c!, d - 1]
(%i20) join(L1, [1, 2, 3, 4]);
(%o20)                [a, 1, sin(b), 2, c!, 3, d - 1, 4]
(%i21) join (L1, [aa, bb, cc, dd, ee, ff]);
(%o21)              [a, aa, sin(b), bb, c!, cc, d - 1, dd]

last(expr)
Returns the last part (term, row, element, etc.) of the expr.

lastn(expr, count)
Returns the last count arguments of expr, if expr has at least count arguments. Returns expr if expr has less than count arguments.

expr may be any nonatomic expression. When expr is something other than a list, lastn returns an expression which has the same operator as expr. count must be a nonnegative integer.

lastn honors the global flag inflag, which governs whether the internal form of an expression is processed (when inflag is true) or the displayed form (when inflag is false).

Note that lastn(expr, 1), which returns a nonatomic expression containing the last argument, is not the same as last(expr), which returns the last argument by itself.

lastn returns the last count elements of expr, if expr has at least count elements.

(%i22) mylist : [1, a, 2, b, 3, x, 4 - y, 2*z + sin(u)];
(%o22)              [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]
(%i23) lastn(mylist, 0);
(%o23)                                []
(%i24) lastn(mylist, 1);
(%o24)                          [2 z + sin(u)]
(%i25) lastn(mylist, 2);
(%o25)                       [4 - y, 2 z + sin(u)]
(%i26) lastn(mylist, 7);
(%o26)               [a, 2, b, 3, x, 4 - y, 2 z + sin(u)]

lastn returns expr if expr has less than count elements.

(%i27) mylist : [1, a, 2, b, 3, x, 4 - y, 2*z + sin(u)];
(%o27)              [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]
(%i28) lastn(mylist, 100);
(%o28)              [1, a, 2, b, 3, x, 4 - y, 2 z + sin(u)]

expr may be any nonatomic expression.

(%i29) myfoo : foo(1, a, 2, b, 3, x, 4 - y, 2*z + sin(u));
(%o29)            foo(1, a, 2, b, 3, x, 4 - y, 2 z + sin(u))
(%i30) lastn(myfoo, 4);
(%o30)                  foo(3, x, 4 - y, 2 z + sin(u))
(%i31) mybar : bar[m, n](1, a, 2, b, 3, x, 4 - y, 2*z + sin(u));
(%o31)          bar    (1, a, 2, b, 3, x, 4 - y, 2 z + sin(u))
                   m, n
(%i32) lastn(mybar, 4);
(%o32)                bar    (3, x, 4 - y, 2 z + sin(u))
                         m, n
(%i33) mymatrix : genmatrix (lambda ([i, j], 10*i + j), 10, 4) $

(%i34) lastn(mymatrix, 3);
                            [ 81   82   83   84  ]
                            [                    ]
(%o34)                      [ 91   92   93   94  ]
                            [                    ]
                            [ 101  102  103  104 ]

lastn honors the global flag inflag.

(%i35) myexpr : a + b + c + d + e;
(%o35)                         e + d + c + b + a
(%i36) lastn(myexpr, 3), inflag=true;
(%o36)                             e + d + c
(%i37) lastn(myexpr, 3), inflag=false;
(%o37)                             c + b + a

Note that lastn(expr, 1) is not the same as last(expr).

(%i40) lastn([w, x, y, z], 1);
(%o40)                                [z]
(%i41) last([w, x, y, z]);
(%o41)                                 z

cit. & loll – 109

Ebbene sì, anche a ferragosto, eccoli 😜

Carlo Nardone

How to be a 10x engineer
::: RichRogersIoT

When I become truly convinced there’s a bug in the compiler
::: RichRogersIoT

A useful habit is keeping a special todo list titled “Low-hanging Fruit” to save easy tasks for moments I feel tired or scattered or demotivated
::: devonzuegel

I soccorritori, ieri, a Bologna hanno dovuto prima di tutto sgombrare le corsie parallele dalle auto ferme per fare i video
::: Hazydavey36

Once you start using C++ lambdas
::: froydnj

Lol @ people saying security is hard
::: KurtBugbee

That’s what’s cool about working with computers
::: CodeWisdom

With good architecture, debugging is a breeze
::: RichRogersIoT

Bad programmers worry about the code
::: RichRogersIoT

No matter how much hype and ads you push on me
::: Gianlucadfiore

What we think about ends up shaping who we are. Be careful what you allow into your social media feeds. In the long run, it will become a part of you
::: fchollet

Our company is like a family
::: YossiKreinin

Falling in love with code
::: CodeWisdom

The Virtual Keypunch
💥 meravigliosa 💥
::: romanzolotarev

DO YOU KNOW WHAT I DISLIKE IS WHEN WEB DEVS THINK THEY’RE VERY CLEVER AND PUT KEYBOARD SHORTCUTS INTO THEIR APP SO YOU PRESS A KEY IN AN ATTEMPT TO TYPE AND INSTEAD THE WEBSITE DOES SOMETHING WEIRD
OK, il tutto-maiuscolo a volte serve
::: mcclure111

How do we convince people that in programming simplicity and clarity
::: jedws

King Kong Finally Makes Sense!
::: tech_faq

Cosa preferiresti per il tuo compleanno, un fratellino o il computer?
::: aedan83

Fixing bugs in production…
::: ThisIsJoshVarty

Watch this industrial robot learn to be a master swordsman
::: Rainmaker1973

Sometimes the problem is
::: CodeWisdom

Phénomène inexpliqué
::: CommitStrip

How to destroy Programmer Productivity
::: RichRogersIoT

Getting moderately good at programming
::: RichRogersIoT

tenere pronta la documentazione
::: lemire

Goal for weekend
::: JohnDCook

Every day, computers are making
::: TheTedNelson

s/scar/horn/
::: tpope

The energy needed to understand a new concept
::: Gianlucadfiore

This Japanese robot sumo literally requires an infinite peak of responsiveness
::: Rainmaker1973

Forgetful development of computing
la risposta di Rainer rockz!
::: monfera

The Stone Age did not end for lack of stones
::: JohnDCook

Too many people in the field of AI are chasing the latest fashions
::: fchollet

I just got my very first software patent! 🎉
::: greenberg

Possibly the biggest damage that the Internet has done to human life has been encapsulating us in the frantic, blinding bubble of an ‘Eternal Present’
::: antoniogm

The beginning of this article was good–and made a lot of sense! Wish I had a @newscientist subscription so I could read the rest. I wonder if paywalls are causing people’s knowledge of cocktail party topics to become even shallower
::: jeanqasaur

#humansoflatecapitalism
::: HumansOfLate

GNU/Hurd With A Vengeance
::: danslimmon

Tech Resistance update
::: Pinboard

Stanotte ho sognato un bug in un mio progetto, stamattina come prima cosa ho controllato ed il bug c’era davvero
::: Genjuro75

Il bello di twitter è che se scrivi una battuta sulle caramelle gommose potresti beccarti il cazziatone di uno che ti dà dell’insensibile
::: ailgamar

Come riconoscere un bot-troll?
::: MauroV1968

Twitter is the place where people who have become famous for doing one thing well
::: TheStoicEmperor

Arguing on Twitter
::: BoringEnormous

What fresh hell is this
::: aloria

Autocorrect
::: mariofusco

future programming languages will solve
::: PLT_cheater

Java Attacks!
::: {turnoff.us}

Reminder that we should be using the 🥖 Baguette emoji as the directory separator
::: willkirkby

Learning basic queuing theory is the worst because you never use it again and all it does is make you angry every time someone makes you split up into multiple lines prematurely at airport security or the grocery store
::: clegoues

Ok Google, Lumos Maxima
::: idajo94

This swarm of robots makes amazing coreographies & achieves complex global behavior
::: Rainmaker1973

Design is the fundamental soul of a man-made creation
::: RichRogersIoT

Honestly I don’t think we’re quite done with bad architecture in bad languages
::: Symbo1ics

I could win that game, but it’s not a game worth winning
::: JohnDCook

For me, one of the most interesting insights to be gained from Twitter
::: fchollet

As programs get large and complicated
::: SICPQuotes

Walmart dress code
::: HumansOfLate

Things developers care about but shouldn’t
::: jdegoes

The most exciting phrase to hear in science
::: CodeWisdom

Hints of unit testing, written in 1957, referring to the previous decade
::: geoffwozniak