I have a variable list in my Makefile like that:
varglob := a1 a2 a3 a4 a5 a6
I want to create a new variable from varglob but eliminate some specific elements for example "a3".
I thought about foreach but my problem is that I don't know how I test with ifneq inside the foreach. So I tried to use shell like that:
varglobelim := $(foreach y, $(varglob), $(shell if [$(y) != "a3"]; then echo $y;fi))
But this solution doesn't success. I get an empty message.
Is there any other suggestions?
filter-out is your friend here:
varglob := a1 a2 a3 a4 a5 a6 b7 b8 b-whatever
has-no-ticket := a3 b% # a3 and all the b's didn't pay the ride
varglobelim := $(filter-out $(has-no-ticket),$(varglob))
Related
I am stuck with a little problem.
i would like to auto-generate a Serie of numbers(is this the right description?):
for example:
The input/value in A1 is 5
the OUTPUT in B1 should now be 1
in
in cell B2 - 2,
B3 - 3,
B4 - 4,
B5 - 5,
B6 - 1, (STARTING at one again)
B7 - 2
. . . and so on until end of range
if I then change the value in A1 to 7 for example it should now "count" from 1 to 7 and repeat until the end of the range again.
any hints available would be much appreciated
=ARRAYFORMULA(MOD(SEQUENCE(ROWS(B2:B),1,0),A1)+1)
this is creating an array of numbers from 0 to however many rows there are on the sheet, then taking the modulus of each number using the value of A1 as a divisor.
MOD() means "what's the remainder after dividing by [n]?" where N in your example case is 6 or 7 or whatever.
Need some help on this cause I'm getting an issue
I've this three columns (Time, R1 and R2) and I'm trying to count the mismatches between R1 and R2 but for each month (on the time column)
I already used a formula but I'm having an issue to add 1.
https://docs.google.com/spreadsheets/d/1bVP79Gbd14lO6xunu2K9POT7y55yrXegD-cTF70Fb4k/edit#gid=0 (the spreadsheet with the values)
=iferror(if(EOMONTH($A64,0)=$A64,SUMPRODUCT(month(Database!$C$2:$C) = month($A64),--(Database!G$2:G <> Database!H$2:H)),""),"Error")
This part "month(Database!$C$4:$C) = month($A5)" is where I compare the information of the months, ( but I'm having an issue cause cause "month(Database!$C$4:$C)" only retrieves 4 that is the month of april)
This part "(Database!G$4:G <> Database!H$4:H)" is where I compare the columns R1 and R2
The part "EOMONTH($A5,0)=$A5" is where I take the month to based myself
Time R1 R2
2020-04-30 BA BU
2020-04-30 BU BA
2020-04-29 BA BU
2020-04-29 BU BA
2020-04-28 BA BU
2020-04-28 AA BA
2020-04-25 AA BA
2020-04-22 BU BA
2020-04-19 AA BU
2020-04-19 AA BA
2020-03-27 BA AA
2020-03-27 BA AA
2020-03-26 BU AA
2020-03-18 BA AA
2020-03-18 AA BU
Approach
In order to validate the answer I created a test Spreadsheet from a copy of your. In this sheet I created two support columns, one which contains the month number: MONTH($A1) and the other one a flag if the two values R1 and R2 are different: IF($B1=$C1,"",1).
In this way I can use this two support structure to validate the numbers obtained by the formula which didn't use any. I will use a much simpler formula this time to compute the sum =SUMIF(D:D,month(<DATE_VALUE>),E:E).
I will link here the test sheet. As you can see the values are the same as the ones obtained by the formula. So, I can confirm that if you are expecting different results, your database is not consistent.
In conclusion the formula: if(EOMONTH($A64,0)=$A64,SUMPRODUCT(month(Database!$C$2:$C) = month($A64),--(Database!G$2:G <> Database!H$2:H)),"") is working correctly.
I'm currently starting a new language (PROLOG) and I came across with a few issues.
I'm developing a simple board game in which I'm required to print the board. I've developed a PrintBoard and initialBoard predicate (as shown below), and I want to be able to run it from the main predicate, just like so:
printBoard([Head|Tail]) :-
printRow(Head),
printBoard(Tail).
printBoard([]).
printRow([Head|Tail]) :-
write(Head),
write(' '),
printRow(Tail).
printRow([]) :- nl.
initialBoard(Board) :- Board = ([
['b0','b0','b0','b0','b1'],
['b0','b0','b0','b0','b0'],
['b0','b0','b0','b0','b0'],
['b0','b0','b0','b0','b0'],
['b2','b0','b0','b0','b0']
]).
main :- Board = initialBoard(Board), printBoard(Board).
By typing main. in the SICStus PROLOG, the program should output the following:
b0 b0 b0 b0 b1
b0 b0 b0 b0 b0
b0 b0 b0 b0 b0
b0 b0 b0 b0 b0
b2 b0 b0 b0 b0
But, instead, it returns nothing. (Returns no).
The only way it seems to work is by inserting the whole list all over again as the variable, just like so:
main :- printBoard(<insert whole list here>).
Even though I'm looking to run it as:
main :- printBoard(initialBoard(Board)).
The portion of code above works, if main is passed the Board argument, but is it possible without passing it?
Functional code:
main(Board) :- printBoard(initialBoard(Board)).
I have a number of text files I'm looking to send to different destinations depending on whether or not the file contains Cyrillic characters using a batch script. For example:
All Files are located in C:\mydocs. The script will be monitoring this file.
File one: contains all English characters > copy to C:\mydocs\English\
File two: Contains some Cyrillic characters > copy to C\mydocs\Contains_Cyrillic\
Is this possible?
It depends on how your text file is encoded. If the file is unicode, then I'm not sure how to test.
But if the file is extended ascii (1 byte per character), then the meaning of bytes > decimal 127 is dependent on the code page. You can't really tell if the file contains Cyrillic, but you can tell if it contains a byte >127 which is likely to be a non-English character.
The following script should work on Windows XP and later - no need to download anything.
It first creates a file that is >= the length of your file, consisting only of the character "A". Then it uses FC to do a binary comparison and pipes the result to FINDSTR which looks for a value >= 0x80. If one is found, then it returns ERRORLEVEL 1, else it returns ERRORLEVEL 0.
#echo off
call :HasExtendedASCII %1 && (echo English) || echo Not English
exit /b
:HasExtendedASCII
setlocal enableDelayedExpansion
set "tempFile=%temp%\dummyFile%random%.txt"
<nul set /p "=A" >"!tempFile!"
set /a dummySize=1
for /l %%N in (1 1 32) do if !dummySize! lss %~z1 (set /a dummySize*=2 & type "!tempFile!" >>"!tempFile!")
fc /b "!tempFile!" %1|findstr /re " [89ABCDEF][0123456789ABCDEF]" >nul&& set rtn=1 || set rtn=0
del "!tempFile!"
exit /b %rtn%
This is not so easy as the cmd works only over the extended ascii table.
Here is a file that contains the cyrillic alphabet printed with type command:
тхЁЄ·єшюярёфЇуїщъыч№Ўцсэьў∙°■╫▐┘╪▀┬┼╨╥┌╙╚╬╧└╤─╘├╒╔╩╦╟▄╓╞┴═╠ (bulgarian cyrillic- may differs with russian , mongolian and etc...)
unfortunately FINDSTR command does not work well with these.
BUT IF the only specaial characters that these files contains are cyrillic may be there's a chance :-).You can check the cyrillic characters by their HEX codes.There's a certutil command that you can use to encode a file to hex , or dump it to hex.Not win xp native but it can be downloaded from microsoft.com .Here are the hex codes:
ff e2 e5 f0 f2 fa f3 e8 ee ef e0 f1 e4 f4 e3 f5
e9 ea eb e7 fc f6 e6 e1 ed ec f7 f9 f8 fe d7 de
d9 d8 df c2 c5 d0 d2 da d3 c8 ce cf c0 d1 c4 d4
c3 d5 c9 ca cb c7 dc d6 c6 c1 cd cc
and here's the code:
#echo off
certutil -dump my.cirillyc.file | findstr /r ""ff" "e2" "e5" "f0" "f2" "fa" "f3" "e8" "ee" "ef" "e0" "f1" "e4" "f4" "e3" "f5" "e9" "ea" "eb" "e7" "fc" "f6" "e6" "e1" "ed" "ec" "f7" "f9" "f8" "fe" "d7" "de" "d9" "d8" "df" "c2" "c5" "d0" "d2" "da" "d3" "c8" "ce" "cf" "c0" "d1" "c4" "d4" "" "c3" "d5" "c9" "ca" "cb" "c7" "dc" "d6" "c6" "c1" "cd" "cc""
if %errorlevel% EQU 0 (
copy my.cirillyc.file C\mydocs\Contains_Cyrillic\
)
May not work so properly if you file contains some of ╓╞┴═╠... symbols but should be ok in the more cases.To traverse all files in a directory you can surround the this with for /f loop
I am trying to understand how Mach-o files work, and have made a good deal of progress with the online resources available (In particular, the Apple page here: http://developer.apple.com/library/mac/#documentation/developertools/conceptual/MachORuntime/Reference/reference.html), but I have hit a roadblock on understanding how symbol stubs work.
Using "otool -l" I see the following section:
Section
sectname __symbolstub1
segname __TEXT
addr 0x00005fc0
size 0x00000040
offset 20416
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000408
However when I look at the data from the binary file in a hex editor I see the following 4 bytes repeated again and again:
00005FC0 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 88
00005FD0 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 88
00005FE0 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 88
00005FF0 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 38 F0 9F E5 88
This looks something like a LDR which increases the PC by a fixed amount, but I don't see why the amount is the same for each entry in the symbol table.
If someone can shed light on why this is so, or provide any resources that get this low level, please let me know.
Thanks!
I will describe the situation with the current iOS, it's somewhat different in the old versions.
The symbol stubs indeed load into the PC a function pointer. For the standard "lazy" (on-demand) imports, the pointer resides in the __lazy_symbol section and initially points to a helper routine in the __stub_helper section, e.g.:
__symbolstub1 _AudioServicesAddSystemSoundCompletion
__symbolstub1 LDR PC, _AudioServicesAddSystemSoundCompletion$lazy_ptr
__symbolstub1 ; End of function _AudioServicesAddSystemSoundCompletion
__lazy_symbol _AudioServicesAddSystemSoundCompletion$lazy_ptr DCD _AudioServicesAddSystemSoundCompletion$stubHelper
__stub_helper _AudioServicesAddSystemSoundCompletion$stubHelper
__stub_helper LDR R12, =nnn ; symbol info offset in the lazy bind table
__stub_helper B dyld_stub_binding_helper
The function dyld_stub_binding_helper is the fist one in the __stub_helper section and essentially is just a trampoline to the dyld_stub_binder function in dyld, passing to it what I call "symbol info offset" value. That value is an offset inside the lazy binding info stream (pointed to by the LC_DYLD_INFO or LC_DYLD_INFO_ONLY load command), which is a sort of bytecode stream with commands for dyld. Typical sequence for a lazy import looks like this:
72: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB(M, 0xYYYYY)
19: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM(NNNN)
40: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM(0x00, '_AudioServicesAddSystemSoundCompletion')
90: BIND_OPCODE_DO_BIND()
here dyld would do the following:
look up function named '_AudioServicesAddSystemSoundCompletion' from
a dylib number NNNN in the list of dylibs listed in the load
commands.
look up the executable's segment number M (most likely __DATA)
write the function pointer at the offset YYYYY.
jump to the looked up address so that the actual function does its job
The address written to happens to be the _AudioServicesAddSystemSoundCompletion$lazy_ptr slot. So, the next time the _AudioServicesAddSystemSoundCompletion is called, it will jump directly to the imported function, without going via dyld.
N.B.: you should not look at the offset 05fc0 in the file right away. The addr field is the virtual address, you should look up the containing segment command and see at what VA it starts and what is its file offset, then do the math. Usually the __TEXT segment starts at 1000.
However, the actual symbol stubs do look like you pasted, probably you have a fat mach-o with the fat header taking the first 1000 bytes, so the offsets line up.