avatarDr. Lisa Galarneau aka Artemis Pax

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3392

Abstract

er">17</span>]</pre></div><blockquote id="c020"><p>Compact Map()</p></blockquote><p id="b1c2"><code>compactMap</code> function is similar to <code>map</code>, but it also includes an additional step, it filters out any <code>nil</code> values that result from applying the transformation closure. This is particularly useful when you have an array of optional values and you want to transform them while simultaneously filtering out the <code>nil</code> elements.</p><div id="9cf9"><pre><span class="hljs-keyword">extension</span> <span class="hljs-title class_">Array</span> { <span class="hljs-keyword">func</span> <span class="hljs-title function_">compactMap</span><<span class="hljs-type">T</span>>(<span class="hljs-keyword">_</span> <span class="hljs-params">transforms</span>: (<span class="hljs-type">Element</span>) -> <span class="hljs-type">T</span>?) -> [<span class="hljs-type">T</span>] { <span class="hljs-keyword">var</span> result <span class="hljs-operator">=</span> <span class="hljs-type">T</span> <span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> <span class="hljs-keyword">self</span> { <span class="hljs-keyword">if</span> <span class="hljs-keyword">let</span> element <span class="hljs-operator">=</span> element { result.append(transform(element)) } } <span class="hljs-keyword">return</span> result } }</pre></div><p id="fe9c">Here the only change from <code>Map</code> and <code>Compact Map</code> is avoiding the nil value with a condition.</p><p id="3b42">In the above code</p><ul><li>It takes a closure <code>transform</code> as an argument, which specifies how each element should be transformed.</li><li>Inside <code>compactMap</code>, a new array <code>result</code> is created to store the transformed non-nil elements.</li><li>It then iterates over each element of the original array (<code>self</code>), applies the transformation closure to each element, and checks if the result is non-nil.</li><li>If the result is non-nil, it appends the transformed element to the <code>result</code> array.</li><li>Finally, it returns the <code>result</code> array containing all the non-nil transformed elements.</li></ul><blockquote id="9909"><p>How to consume it?</p></blockquote><div id="41f1"><pre><span class="hljs-keyword">let</span> mapArray <span class="hljs-operator">=</span> [<span class="hljs-number">23</span>, <span class="hljs-number">43</span>, <span class="hljs-number">56</span>, <span class="hljs-literal">nil</span>, <span class="hljs-number">75</span>, <span class="hljs-number">9</span>, <span class="hljs-number">14</span>] <span class="hljs-keyword">let</span> result<span class="hljs-operator">=</span> mapArray.compactMap { <span class="hljs-variable">$0</span> } <span class="hljs-built_in">debugPrint</span>(result) output: [<span class="hljs-number">23</span>, <span class="hljs-number">43</span>, <span class="hljs-number">56</span>, <span class="hljs-number">75</span>, <span class="hljs-number">9</span>, <span class="hljs-number">14</span>]</pre></div><blockquote id="854c"><p>Flat Map()</p></blockquote><p id="b656">FlatMap is typically the same as <code>map</code> does, only difference is that it always return flatten array joining all elements. Typically used to collect specific data in n

Options

ested array, dictionary or set</p><div id="6431"><pre><span class="hljs-keyword">extension</span> <span class="hljs-title class_">Array</span> { <span class="hljs-keyword">func</span> <span class="hljs-title function_">flatMap</span><<span class="hljs-type">T</span>>(<span class="hljs-keyword">_</span> <span class="hljs-params">transform</span>: (<span class="hljs-type">Element</span>) -> [<span class="hljs-type">T</span>]) -> [<span class="hljs-type">T</span>] { <span class="hljs-keyword">var</span> result <span class="hljs-operator">=</span> <span class="hljs-type">T</span> <span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> <span class="hljs-keyword">self</span> { result.append(contentsOf: transform(element)) } <span class="hljs-keyword">return</span> result } }</pre></div><p id="75fa">In the above code</p><ul><li>It takes a closure <code>transform</code> as an argument, which specifies how each element should be transformed into a sequence.</li><li>Inside <code>flatMap</code>, a new array <code>result</code> is created to store the flattened elements.</li><li>It then iterates over each element of the original array (<code>self</code>), applies the transformation closure to each element, and concatenates the resulting sequences into the <code>result</code> array.</li><li><code>append(contentsOf: )</code> will add the elements of a sequence to the end of the array.</li><li>Finally, it returns the <code>result</code> array containing all the flattened elements.</li></ul><blockquote id="2285"><p>How to consume it?</p></blockquote><div id="117f"><pre><span class="hljs-keyword">let</span> arrayOfArrays <span class="hljs-operator">=</span> [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]] <span class="hljs-keyword">let</span> transformedArray <span class="hljs-operator">=</span> arrayOfArrays.flatMap { <span class="hljs-variable">$0</span> } <span class="hljs-built_in">print</span>(transformedArray) output: [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>]</pre></div><h1 id="3bda">Conclusion</h1><p id="057c">There are plenty of other use cases for higher-order functions. This is a gist of what we have discovered today:</p><ul><li>If you need to simply transform a value to another value, then use <code>map</code>.</li><li>If you need to remove nil values, then use <code>compactMap</code>.</li><li>If you need to flatten your result one level down, then use <code>flatMap</code>.</li></ul><p id="0a10">Thank you for your time and attention! 👏👏👏</p><p id="33e6">Do clap👏 if you like this and comment your suggestions!!! <i>Happy coding</i>!!!</p><blockquote id="1e0c"><p>Source Code: <a href="https://github.com/Vikassingamsetty/HigherOrderFunctions.git">GitHub</a></p></blockquote></article></body>

How to Discuss and Report on Extraterrestrial/Extradimensional Intelligence

We live in trying but exciting times, however the majority of people are missing what is quite possibly the most monumental story of our time. First (or open) contact with extraterrestrial and/or extradimensional beings appears to be right around the corner. So why isn’t this bigger news?

There are certain themes that inevitably arise whenever the topic of UFOs or extraterrestrials comes up, as if any serious intellectual investigation must be derided or undermined.

We are trying to contact ET

Most respected, scientific sources say the same thing. We have been trying to contact ET for decades now, but no one appears to be listening. There has been a lot of recent disclosure about planets that could possibly harbor life as we know it, but there is seldom any discussion of what such an eventuality could mean to humanity.

The truth embargo, media blackout, and why everyone makes fun of UFOs and ETs

The simple fact of the matter is that UFOs and extraterrestrials are taboo subjects in our culture. What most people don’t realize is that they have been deliberately manipulated through pop culture and official media sources in order to maintain the cover-up as a matter of government policy.

The Truth Embargo can be defined as the officially imposed ban on revealing the truth with regard to the extraterrestrial presence on earth. As such it includes — yet is not limited to — the phenomenon of the UFO Cover-up (which is just one aspect of the Truth Embargo). (http://www.exopaedia.org/)

Themes from 2016 news coverage

Guidelines to remember when reporting on or discussing these phenomena

  • Don’t be tempted to use words like crazy, kooky, etc. We have considerable scientific evidence that we live in a universe teaming with life. NASA recently reported having identified over 1200 planets using the Kepler telescope and this is a mere fraction of the planets associated with the hundred of thousands of galaxies we know exist. It is crazy not to consider the possibility of life outside of our small planet in a tiny region of the observable universe. Disclosure is a scientific endeavor and should be treated with the respect for rational inquiry it deserves.
  • Do not insist on tying real world efforts to fiction as a way of discrediting them. It’s okay to refer to these mysteries as ‘real-life x-files’ but don’t simultaneously allude or insist that the disclosure efforts are also fictional.
  • Pose questions seriously without the nervous laugh that has become a societal norm. Ask the more interesting questions: what would contact with extraterrestrial or extradimensional beings mean to humankind?
  • Use consistent, scientific terminology and data sources and avoid words/phrases like ‘aliens’ and ‘little green men’. Try not to overuse the term UFO as UFOs can be of both terrestrial and extraterrestrial origins. Do refer to disclosure, open contact, extraterrestrials, exo-politics, unexplained aerial phenomena (UAP), and other serious terminology.
  • Don’t use images that reinforces stereotypes or presents the person involved in a ‘crazy’ light. Some might feel it is balanced journalism, but reporting on coverage that clearly makes fun of the topic undermines facts like Clinton’s involvement in the disclosure-oriented Rockefeller Initiative (photo, right below).
  • Be careful that your IT people don’t add their own twist to article meta-data like titles and image descriptions. The Washington Post wrote a nice article, but if you look at the URL, the bias is plain as day: http://www.washingtontimes.com/news/2015/jan/20/inside-the-beltway-space-alien-lobbyist-argues-for/?page=all
  • Be willing to read between the lines. There is some good stuff emerging on late night television shows like Jimmy Kimmel, where everything is of course couched in a joke. These comments are what we refer to as ‘soft disclosure’ which means people in the know dropping hints about more disclosure to come.

To report in any other way means you are supporting the truth embargo by casting doubt on any facts or evidence presented.

A decent example article:

http://www.thewhig.com/2016/05/16/the-truth-about-ufos-is-out-there

About the author:

Dr. Galarneau is a socio-cultural anthropologist, media scholar, and former journalism/mass communications professor. She is also a #Disclosure Activist.

Space
Disclosure
Journalism
Aliens
Media
Recommended from ReadMedium