Home   Help Search Login Register  

Author Topic: Names for functions  (Read 3610 times)

0 Members and 1 Guest are viewing this topic.

Offline SoldierEPilot

  • Members
  • *
Names for functions
« on: 23 Mar 2017, 20:28:17 »
A topic to ask the last 2.5 men standing
about good English names for SQF functions.

-----------------------------------------------------------

I have 6  fns to apply some code to OFP array(s)
and to collect the result into array.
An inspiration mainly comes from here:
http://en.wikipedia.org/wiki/Map_(higher-order_function)

map - executes the code 4 each array element;
map_self - ...4 each array element, the result will be
written into original array;
map_rec - ...4 each array element on the deepest
recursion level (4 each non-array);
map_if - ..4 each array element, satisfying some condition;
map2 - ...tween each corresponded elements of two arrays;
map2_rec - ..tween each corresponded non-array elements
of two arrays (recursion);

All but "map_self" returns an array.
For example:
Code: [Select]
[[1,2,3],{_x / _y},[1,2,3]] call map2returns [1,1,1].
Code: [Select]
[ [1,2,[3]], {_x^2} ] call map_recreturns [1,4,[9]].

The problem: "map" is associated with island map, so
I need to use another short word as a name base.
"Do" & "forEach" are already present in the command list.
Could someone offer english word which fits the task
and shorter when "apply"?
Maybe "ply" or "hof" (higher-order function)...
Any ideas?





Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Names for functions
« Reply #1 on: 24 Mar 2017, 18:46:26 »
Out of curiosity, why it has to be shorter than 'apply'?
'ply' would be fitting abbreviation of that I guess. Or 'apl', which sounds like 'apple' though..

Also curious as to which one of us is only 0.5 Man..  :scratch:
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline SoldierEPilot

  • Members
  • *
Re: Names for functions
« Reply #2 on: 25 Mar 2017, 08:49:10 »
>which one of us is only 0.5 Man
Or 2 * 1.25  :cool2:
A popular word construction
from Russian OFP community -
"3.5 men who makes OFP missions" etc.
Sad, but nearly true.

OK, looks like "apply" is short enough.
3 more awkward names.

building_points - all existing
"buildingPos" positions in building.
Note what NearestBuilding command works only
with buildings, not with houses without inner positions.

delim_point - point what separates p1-p2 segment
into 2 parts with some length ratio (default = 1/1).

z_angle/elevation_angle - elevation angle from
one ASL position to another.

Need more clear and shorter (if possible) names 4 them.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Names for functions
« Reply #3 on: 25 Mar 2017, 17:58:55 »
I don't really see the point in trying to force function names short (the game itself doesn't care) :dunno: , and making short and clear names starts be a bit of an oxymoron really.

I'd rather try to name them so that the name of the function pretty clearly tells you what it does (someone starting up just gets confused if the function name is too 'codery') regardless of the length.
Like for example BIS' own function that returns the building positions of a given building (in A2/3) is called BIS_fnc_buildingPositions; it's pretty clear on what it does although getBuildingPositions would have been clearer still I guess.

So can't really see how delim_point or elevation_angle/z_angle could be made shorter and clear at the same time. :dunno:
« Last Edit: 25 Mar 2017, 18:05:53 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline SoldierEPilot

  • Members
  • *
Re: Names for functions
« Reply #4 on: 25 Mar 2017, 20:15:40 »
Let a clearance be a "fit function".

"building_positions" IMO looks good enough.
What can you recommend for the rest 2?

// added
delim_point alternatives: section, midpoint, section_point.
Which one is better?
« Last Edit: 26 Mar 2017, 16:34:18 by SoldierEPilot »

Offline SoldierEPilot

  • Members
  • *
Re: Names for functions
« Reply #5 on: 09 Apr 2017, 16:52:04 »
Suspicious / irrelevant names:

no_doubles:
Code: [Select]
["g","o","o","d"] call no_doublesreturns
Code: [Select]
["g","o","d"]It also removes triplets, 4-letter repeats etc,
so "no_doubles" isn't a strong enough word.

swap_identity - provides "body exchange" for 2
non-player units. The first one will get voice, face
and glasses of another and vice versa.

symbol_counts - how many times latin letters and
"0-9" digit chars are present in given char vector?
Returns 36 integers.

symbol_counts2 - a version with custom symbol set.

type_list - actualy 2 lists: one list of unique elements,
and another one of their counts. But in OFP list is
associated with a simple array (of units).

unwrap_type_list - makes reverse process:
Code: [Select]
[[1,3,2],["hk","m16","grenade"]] call unwrap_type_listreturns
Code: [Select]
["hk","m16","m16","m16","grenade","grenade]

Re: Names for functions
« Reply #6 on: 14 May 2018, 15:26:39 »
i dont get it what is this all about? XD

Offline SoldierEPilot

  • Members
  • *
Re: Names for functions
« Reply #7 on: 18 May 2018, 00:35:54 »
It's about this function pack:
http://www.ofpec.com/forum/index.php?topic=36435.0
See the last msg for an actual version link.

There are 3 test missions in the package, allmighty "apply" fns
are shown in work in the first one, topic name in the combo box = "Arrays".

One more sample:
Code: [Select]
_AT_guys = [units player, {secondaryWeapon _x!=""}] call localize "f_apply_if"